13

I have an android device (Android 4.4) with two launchers. One comes with the device and the other one is home made. I have the following questions regarding this scenario:

  1. How can I set the default launcher via ADB? (same as selecting one and pressing Always)
  2. How can I clear the default launcher selection via ADB? (same as entering to Default Applications and clearing Defaults)

Please do not submit answers or comments that do not consider the use of ADB. I'm not interested in any of those.

Also, I already know about disabling one of the launchers via ADB (pm disable app_package_name) and then re-enabling it, but this is not the same as setting the default launcher or setting the preferred activity. You can see the difference in the next image:

enter image description here

2
  • 2
    Is the use of Key Events permitted? Also, setting for default apps is stored inside /data/system/users/USERID/package-restrictions.xml. Users can't write it without root access.
    – Firelord
    Apr 20, 2016 at 14:17
  • @Firelord No, it is not permitted the use of Key Events. Still +1 for the idea, maybe for the future. Regarding the /data/system/users/USERID/package-restrictions.xml file, that is exactly what running pm disable app_package_name and then pm enable app_package_name does.
    – Storo
    Jun 3, 2016 at 16:10

3 Answers 3

5

It is not necessary to uninstall the default launcher, you must know it's package name before of doing so, which if you don't know you must get with adb shell cmd shortcut get-default-launcher.

In order to set your launcher as default you just have to call the following

adb shell cmd package set-home-activity "your.package/.YourLauncherActivity"
4
  • How do you revert this setting?
    – Sergio
    Apr 5 at 22:11
  • @Sergio, the fast way is uninstalling your home application and the original one is automatically set back as default. The (IMO) best way is finding in advance, before of applying your launcher, the original one with adb shell cmd shortcut get-default-launcher and use its package name and activity name to manually set it back as default with adb shell cmd package set-home-activity "your.package/.YourLauncherActivity" Apr 7 at 7:32
  • @Sergio I have to make a clarification on my previous comment: if you have more than 2 home launcher applications, uninstalling your custom one will probably not automatically set the original one as default but it will trigger the picker where you have to manually chose the one you want. Another reason why setting it back by knowing its package/activity name in advance is the best way. Apr 7 at 7:58
  • Thanks for the reply. Finding the default package before setting a new one is a good idea.
    – Sergio
    Apr 7 at 11:51
1

you can remove (Uninstall) the default program you set using ADB by doing this :

adb uninstall app.package  ..... //for example (com.example.homeapp)

If you don't want to remove the app .. here is a quick hack to do it:

  • adb shell
  • am start -a android.intent.action.MAIN

That way you will have a picker with all apps on your devices that listens to Main Action

  • Choose any home screen app you want . then go to settings and set it as default.

Copied from this answer

1

I know this is not the answer of the asked question, anyways this may helps someone regarding setting default app links (deep-links):

Android 12+ (since API 31)

adb shell pm set-app-links --package [PACKAGE_NAME] 1 [URL_HOST]

e.g. adb shell pm set-app-links --package com.company.myapp 1 myapp.company.com

Android 11- (API 30 and below)

adb shell pm set-app-link [PACKAGE_NAME] always

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .