To implement such a function, the program can listen for screen unlocking events and automatically start the application if a screen unlocking event occurs.
Implementation method: When the screen is unlocked, the system will broadcast the unlocked event, just register a listener in the program to listen to unlock the event broadcast.
Declare the broadcast in the Androidmanifest file, where it is more important to filter the settings and declare <action android:name= in the <intent-infilter> Android.intent.action.USER_PRESENT ">
Tip: At first you need to know screen_on this listener needs to be dynamically added if it is not reacted by statically adding to the Androidmanifest file
Then you need to be aware of how to start the application by broadcasting.
In broadcast, the method is onreceive by overloading the parent class method, which starts the activity in the method that is executed after the Broadcastreceiver receives the broadcast.
Declare intent to start an activity in the broadcast onreceive. Intent Intent = new Intent (context,activity.class);
Here you need to pay attention, at this time not through intent to start the application, why. Each application should have its own activity stack, which is used to store open activity, but because it did not open the application before, the stack does not exist, it needs to be prepared in advance, by setting intent can implement this stack creation.
Intent.setflags (Intent.flag_activity_new_task) enables the creation of stacks, the flag-activity_new_task of which is that if there is no such stack for the application, the new one, if any, is directly used, very effective.
The starting intent is also through context.startactivity (intent);
So the application will start up.