0

I have 2 questions about launcher below:

  1. I have 3-4 launchers on device, how can i know which launcher has been set default on my device (with code).(Done)

  2. I have own custom launcher app, I want clear default launcher on my app and without use:

    Intent uninstallIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageURI);
    uninstallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    startActivity(uninstallIntent);
    

    as some app as: Kid's Shell or Kids Place. I have try follow Clearing and setting the default home application but nothing change.

Please show me how to solve 2 things. Thanks for any advise.

Community
  • 1
  • 1
dleviathan
  • 87
  • 1
  • 2
  • 17

1 Answers1

1

getPackageManager().clearPackagePreferredActivities(defaultLauncherPackgeName);

Added:

If you want to set your launcher as default, try:

     ComponentName cN = new ComponentName(mContext, FakeHome.class);
     p.setComponentEnabledSetting(cN, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,             PackageManager.DONT_KILL_APP);

     Intent selector = new Intent(Intent.ACTION_MAIN);
     selector.addCategory(Intent.CATEGORY_HOME);
     mContext.startActivity(selector);

     p.setComponentEnabledSetting(cN, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,            PackageManager.DONT_KILL_APP);

And in AndroidManifest.xml:

    <activity
         android:name="com.test.FakeHome"
         android:enabled="false" >
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />

             <category android:name="android.intent.category.HOME" />
             <category android:name="android.intent.category.DEFAULT" />
         </intent-filter>
     </activity>
Isaiah
  • 432
  • 2
  • 6
  • Can i set default launcher for device without checking default on intent of device? – dleviathan Sep 06 '13 at 09:47
  • Some devices allow you to set default launcher without clear the default, but some do not. So you'd better clear the default setting first, then set the default launcher. – Isaiah Sep 06 '13 at 14:12
  • @lsaiah: I can't clear default launcher which not my launcher by your code. How to clear it? thanks – dleviathan Sep 09 '13 at 08:58
  • @dleviathan Your application can only clear its own package, and it is system behavior to set the default app. – Isaiah Sep 10 '13 at 01:54
  • 1
    @dleviathan If you want to set your app as default app, try: ComponentName cN = new ComponentName(mContext, FakeHome.class); p.setComponentEnabledSetting(cN, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); Intent selector = new Intent(Intent.ACTION_MAIN); selector.addCategory(Intent.CATEGORY_HOME); mContext.startActivity(selector); p.setComponentEnabledSetting(cN, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); – Isaiah Sep 10 '13 at 01:54
  • 1
    @dleviathan FaceHome in xml: Just see my edit. – Isaiah Sep 10 '13 at 01:56
  • @lsaiah: Thanks! I have try this but I have problem as [here](http://stackoverflow.com/questions/18697253/load-launcher-app-again/18698035?noredirect=1#18698035) with xml as ` ` – dleviathan Sep 10 '13 at 03:08
  • Have you try to remove `` You know other launchers(Default Android launcher, etc) do not contain this category – Isaiah Sep 10 '13 at 04:21
  • But i want my app run as both normal app and launcher (like some parental control). How i can do that? – dleviathan Sep 10 '13 at 15:30
  • Try to add a separate IntentFilter to the activity: ` ` – Isaiah Sep 11 '13 at 15:00