Package com. example. openstart; import android. app. keyguardManager; import android. app. keyguardManager. keyguardLock; import android. content. broadcastReceiver; import android. content. context; import android. content. intent; import android. util. log; public class MPUStartBroadcastReceiver extends BroadcastReceiver {/*** receives broadcast completed by system startup **/@ Overridepublic void onReceive (Context context, Intent intent) {// cancel KeyguardManager mKeyguardManager = (KeyguardManager) context. getSystemService (Context. KEYGUARD_SERVICE); KeyguardLock mKeyguardLock = mKeyguardManager. newKeyguardLock ("MainActivity"); mKeyguardLock. disableKeyguard (); intent = new Intent (context, MainActivity. class); intent. setFlags (Intent. FLAG_ACTIVITY_NEW_TASK); context. startActivity (intent); // start intention }}
Manifest. xml configuration
Register and receive system startup Broadcast
Add Permissions
RECEIVE_BOOT_COMPLETED system starts broadcasting
DISABLE_KEYGUARD allows the program to disable the keyboard lock