When multiple launchers are started, only the default

Source: Internet
Author: User

Method 1:

--- a/services/java/com/android/server/pm/PackageManagerService.java+++ b/services/java/com/android/server/pm/PackageManagerService.java@@ -2839,6 +2839,13 @@ public class PackageManagerService extends IPackageManager.Stub {             int flags, int userId) {         if (!sUserManager.exists(userId)) return null;         List<ResolveInfo> query = queryIntentActivities(intent, resolvedType, flags, userId);+        Slog.e("sclu", "size = " + query.size());+    for(int i = 0; i < query.size(); i++){+        Slog.e("sclu", query.get(i).activityInfo.packageName);+        if(query.get(i).activityInfo.packageName.equals("com.android.launcher")){+            query.remove(i);+        }+    }         return chooseBestActivity(intent, resolvedType, flags, query, userId);     } @@ -2992,6 +2999,7 @@ public class PackageManagerService extends IPackageManager.Stub {                 ri.activityInfo = ai;                 list.add(ri);             }+             return list;         } @@ -3020,6 +3028,13 @@ public class PackageManagerService extends IPackageManager.Stub {         List<ResolveInfo> results = queryIntentActivities(intent, resolvedType, flags                 | PackageManager.GET_RESOLVED_FILTER, userId); +        Slog.e("sclu ", "size = " + results.size());+    for(int i = 0; i < results.size(); i++){+        Slog.e("sclu", results.get(i).activityInfo.packageName);+        if(results.get(i).activityInfo.packageName.equals("com.myapphone.logicom.tabkids")){+            results.remove(i);+        }+    }         if (DEBUG_INTENT_MATCHING) {             Log.v(TAG, "Query " + intent + ": " + results);         }

Method 2:

Add Android: Priority to androidmanifest. XML to be started by default to increase the priority of broadcast receiving. The higher the value, the higher the priority. In this way, it will first receive the Android. Intent. Category. Home broadcast, as I wrote:

        <activity android:name=".MainActivity"            android:excludeFromRecents="true">            <intent-filter android:priority="3">                                                                                                                               <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.HOME" />                <category android:name="android.intent.category.LAUNCHER" />                <category android:name="android.intent.category.DEFAULT" />            </intent-filter>        </activity>        <activity

In fact, I want to say that this method is really useful. For example, if there are multiple video players, each time I click a video, I just want to use gallery to play the video, so I am receiving android. intent. action. set Android: priority in intent-filter of view.

For Android: Priority usage, the official instructions are as follows:

android:priority
The priority that shocould be given to the parent component withregard to handling intents of the type described by the filter. This attribute has meaning for both activities and broadcastreceivers:
  • It provides information about how able an activity is torespond to an intent that matches the filter, relative to otheractivities that cocould also respond to the intent. when an intentcocould be handled by multiple activities with different priorities, Android
    Will consider only those with higher priority values aspotential targets for the intent.
  • It controls the order in which broadcast receivers are executedto receive broadcast messages. those with higher priority valuesare called before those with lower values. (The Order applies onlyto synchronous messages; it's ignored for asynchronousmessages .)

Use this attribute only if you really need to impose a specificorder in which the broadcasts are stored ed, or want to forceandroid to prefer one activity over others.

The value must be an integer, such"100". Highernumbers have a higher priority

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.