When it comes to developing an Android system, there are times when you encounter a need to:
Because it is an independent brand, also involves a service in the push, so hope launcher can be fixed, third party can install, but press the home key, must return the system default launcher
Through the analysis of the home key process, found that can be very simple to do, and now share with you:
Path: Frameworks\base\policy\src\com\android\internal\policy\impl\phonewindowmanager.java
<pre name= "code" class= "java" >public void init (context context, Iwindowmanager WindowManager, Windowmanagerfuncs Windowmanagerfuncs) {.... Mhomeintent = New Intent (Intent.action_main, null); Mhomeintent.addcategory (intent.category_home); Mhomeintent.addflags (Intent.flag_activity_new_task | intent.flag_activity_reset_task_if_needed);.}
Modified to:
public void init (context context, Iwindowmanager WindowManager, windowmanagerfuncs windowmanagerfuncs) {.... ComponentName mhomecom = new ComponentName ("Com.android.launcher3", "Com.android.launcher3.Launcher"); Mhomeintent = New Intent (Intent.action_main, null); Mhomeintent.addcategory (intent.category_home); Mhomeintent.setcomponent (mhomecom); Mhomeintent.addflags (Intent.flag_activity_new_task | intent.flag_activity_reset_task_if_needed);.}
That is to add a setcomponent condition in this, componentname needs to be changed to what you need.
Proven, completely ready to handle
How to fix launcher on Android system