When there are multiple launcher desktops in the system, the default launcher can be set in the following ways:
Method One:
Lazy words, will not want to launcher, such as Launcher3 Androidmanifest.xml file in the home attribute removed, only to retain their own launcher can, if we have other launcher source. The disadvantage is that the home attribute is removed and cannot be entered.
Method Two:
1. Edit:
Frameworks/base/services/java/com/android/server/pm/packagemanagerservice.java
In the file
public void Systemready () {} function, add the following code snippet at the end:
Tchip ZJADDBelow for Default Launcher if (Isfirstboot ()) {//modified to the package name String that needs to be set Examplepackag ename ="Com.tchip.carlauncher";Modify the launcher activity name String Exampleactivityname = to be set"Com.tchip.carlauncher.ui.activity.MainActivity";Intent Intent = new Intent (Intent. ACTION_main);Intent. Addcategory(Intent. CATEGORY_home);Final int callinguserid = Userhandle. Getcallinguserid();list<resolveinfo> resolveinfolist = queryintentactivities (Intent, NULL, Packagemanager. GET_meta_data, Callinguserid);if (resolveinfolist! = null) {int size = Resolveinfolist. Size();for (int j =0; j < size;) {Final ResolveInfo r = resolveinfolist. Get(j);if (!r. Activityinfo. PackageName. Equals(Examplepackagename)) {Resolveinfolist. Remove(j);Size-=1;} else {J + +;}} componentname[]Set= new Componentname[size];ComponentName defaultlauncher = new ComponentName (Examplepackagename, Exampleactivityname);int defaultmatch =0;for (int i =0; i < size; i++) {Final ResolveInfo ResolveInfo = resolveinfolist. Get(i); Set[I] = new ComponentName (resolveInfo. Activityinfo. PackageName, ResolveInfo. Activityinfo. Name);if (defaultlauncher. GetClassName(). Equals(ResolveInfo. Activityinfo. Name) {Defaultmatch = ResolveInfo. Match;}} intentfilter filter = new Intentfilter ();Filter. Addaction(Intent. ACTION_main);Filter. Addcategory(Intent. CATEGORY_home);Filter. Addcategory(Intent. CATEGORY_default);AddPreferredActivity2 (filter, Defaultmatch,Set, Defaultlauncher);}}//Tchip ZJADDAbove for Default Launcher
2. Add the following function:
/** * tchip ZJ Add for Default Launcher * / Public void AddPreferredActivity2(Intentfilter filter,intMatch, componentname[] set, componentname activity) {LOG.D ("Debug_default","AddPreferredActivity2 is called.");//Writer synchronized(mpackages) {SLOG.I (TAG,"Adding Preferred activity"+ Activity +":"); Filter.dump (NewLogprinter (Log.info, TAG)," "); MSETTINGS.EDITPREFERREDACTIVITIESLPW (0). addfilter (NewPreferredactivity (filter, match, set, activity,true)); Schedulewritesettingslocked (); } }
3. Modify the Packagemanagerservice.java function findpreferredactivity:
(1) The condition judgment of the removematches, not remove when launcher:
if (! ( Intent. Getaction()! = NULL && Intent. Getaction(). Equals(Intent. ACTION_main) && Intent. GetCategories()! = NULL && Intent. GetCategories(). Contains(Intent. CATEGORY_home))) {Slog. D(TAG,"Launcher");} else {if (removematches) {PIR. removefilter(PA);if (debug_preferred) {Slog. V(TAG,"removing match"+ PA. Mpref. Mcomponent);} Break;}}
(2)
if (Always &&!PA. Mpref. Sameset(query, priority)) {Slog. I(TAG,"Result set changed, dropping preferred activity for"+ Intent +"Type"+ Resolvedtype);if (debug_preferred) {Slog. V(TAG,"Removing preferred activity since set changed"+ PA. Mpref. Mcomponent);} PIR. removefilter(PA);re-AddThe filter as a"Last Chosen"Entry (!always) preferredactivity Lastchosen = new Preferredactivity (PA, PA. Mpref. Mmatch, NULL, PA. Mpref. Mcomponent, false);Pir. addfilter(Lastchosen);Msettings. WRITEPACKAGERESTRICTIONSLPR(userId);return null;}
The above paragraph is modified to read:
if(Always&& !Pa.Mpref.Sameset (query, priority)) {if(!(Intent.Getaction ()!= NULL &&Intent.Getaction ().equals(Intent.Action_main)&&Intent.GetCategories ()!= NULL &&Intent.GetCategories ().Contains (intent.Category_home)) {//MTK ADDSlog.ITAG,"Result set changed, dropping preferred activity for" +Intent+ "Type" +Resolvedtype);if(debug_preferred) {Slog.VTAG,"Removing preferred activity since set changed" +Pa.Mpref.Mcomponent); } PIR.Removefilter (PA);//Re-add the filter as a "last Chosen" entry (!always)Preferredactivity Lastchosen= NewPreferredactivity (PA, PA.Mpref.Mmatch,NULLPa.Mpref.Mcomponent,false); Pir.AddFilter (Lastchosen); Msettings.WRITEPACKAGERESTRICTIONSLPR (USERID);return NULL; }} Slog.ITAG,' Result set not ' change, ' not ' drop preferred activity for special intent: ' +Intent);//MTK ADD //yay! Either the set matched or we ' re looking for the last chosen
Copyright Notice: This article original, reproduced please indicate the source: Http://blog.csdn.net/zhoumushui
Android Settings Default launcher