15

I set one of the program as default launcher program and default setting program so I cannot change the default programs now, can I change the default programs from android-sdk\android-sdk\platform-tools\adb.exe or remote shell.

How can I do that?

And can I remove the defaults of program in Java code?

Lii
  • 11,553
  • 8
  • 64
  • 88
  • Please refer to this link for precise answer: https://android.stackexchange.com/questions/142880/setting-default-applications-through-adb – SameeHsn Dec 13 '19 at 10:05

5 Answers5

22

For system apps you can't uninstall, use pm disable as in

adb shell pm disable com.android.launcher

arne
  • 291
  • 2
  • 3
  • 1
    This should be the accepted answer, use adb shell to disable one of the launcher apps that you do not want. – kev Nov 10 '16 at 07:54
  • 2
    Trying to disable the system launcher, I get: Error: java.lang.SecurityException: Permission Denial – Brent K. Oct 22 '19 at 21:26
  • Yeah, the problem is the default system launcher. – oxr463 Jan 09 '20 at 16:40
  • Thanks, needed this to disable `com.android.server.telecom` and `com.android.dialer` – fabiomaia Oct 08 '20 at 09:44
  • 2
    @BrentK. @rage , there is sometimes problem with permissions... Try `adb shell pm disable-user --user 0 [launcher.app]` to prevent it from starting after reboot... For example i use `adb shell pm disable-user --user 0 com.android.systemui` to prevent systemUI from showing up (home,back,tasks buttons and notifications bar are not starting after reboot) – Mykola Kikets Dec 05 '20 at 21:35
  • @MykolaKikets solution worked for me. In my case what worked for me was `adb shell su ` and then repeatedly run `adb shell pm disable-user --user 0 ru.softcomlan.kioskmodelauncher` until it succeeded while starting up the device (in my case the launcher was disabling adb when started) – josue.0 Oct 11 '22 at 07:57
21

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.
Mr.Me
  • 9,192
  • 5
  • 39
  • 51
  • 1
    Just tested a way you can use to achieve what you want – Mr.Me Feb 11 '13 at 17:22
  • 1
    you saved my job boss :) – Jeffy May 24 '17 at 17:36
  • 1
    I understood the question to be how to change the launcher with adb without having to uninstall / install – dljava Oct 25 '17 at 00:51
  • 1
    Error: Activity not started, unable to resolve intent { act=android.intent.action.main flag=0x10000000 } @Mr.Me – Shayan Dec 30 '18 at 22:57
  • 1
    adb shell am start -a android.intent.action.MAIN Starting: Intent { act=android.intent.action.MAIN } Security exception: Permission Denial: starting Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.android.vending/com.google.android.finsky.setupui.VpaSelectionOptionalStepActivity } from null (pid=22627, uid=2000) requires com.android.vending.setup.PLAY_SETUP_SERVICE – gman Aug 08 '21 at 19:10
  • adb -s 192.168.1.218:5555 shell am start -a android.intent.action.MAIN produces java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.android.vending/com.google.android.finsky.setupui.VpaSelectionOptionalStepActivity } from null (pid=7314, uid=2000) requires com.android.vending.setup.PLAY_SETUP_SERVICE However, entering the shell then su, then am command says "Starting: Intent { act=android.intent.action.MAIN }" but nothing (app picker) appeared on the device screen? – Meryan Apr 15 '22 at 03:50
  • never mind this hack (stupidly long command) worked adb -s 192.168.1.218:5555 shell cmd package set-home-activity com.hisight.mslauncher/com.hisight.mslauncher.MainActivity – Meryan Apr 15 '22 at 04:33
12

adb shell cmd package set-home-activity "package/activity"

adb reboot

dljava
  • 1,825
  • 17
  • 14
  • 1
    `/system/bin/sh: cmd: not found` What android version do you need for this to work? Where do you get `cmd`? EDIT: It doesn't work on API 19 but works on API 24 emulator. – Eugen Pechanec Nov 05 '17 at 20:15
  • correct, sorry I failed to mention this was recently added – dljava Nov 05 '17 at 20:21
  • I followed the source to [PackageManagerShellCommand](https://github.com/aosp-mirror/platform_frameworks_base/blob/nougat-release/services/core/java/com/android/server/pm/PackageManagerShellCommand.java) and [PackageManagerService#setHomeActivity](https://github.com/aosp-mirror/platform_frameworks_base/blob/3de09838fb0996bb4b420630800ad34e828fd1b6/services/core/java/com/android/server/pm/PackageManagerService.java#L17629) and yes, it's been added in API 24. But more importantly it looks pretty hooked up to system so **reboot shouldn't be necessary**. – Eugen Pechanec Nov 05 '17 at 20:40
  • 1
    What's "package/activity"? I get error component can be home on user 0 – Shayan Dec 30 '18 at 22:43
  • 7
    The command actually is `adb shell pm set-home-activity "package/activity"` where package/activity has to be substituted by package name/main activity of the desired launcher. The command is available from API 24/Nougat/Android 7 – Ivin Mar 10 '19 at 15:47
  • This must be the accepted answer. Anyway `adb reboot` may not be needed in some devices (with Samsung SM-T813 you just have to press the home button). Thank you! – Cliff Burton Jul 25 '19 at 09:34
1

The key is adb. Once you know the package name of the app you wish to clear data for, try:

adb shell pm clear package.name.of.app

It'll clear all data for the app, but I don't know of a way to only clear the defaults.

Krylez
  • 17,414
  • 4
  • 32
  • 41
1

You can check and change the default sms app by using adb shell settings get secure sms_default_application and then use adb shell settings put secure sms_default_application <package name>. I'm not sure about the other default apps, but it's just a matter of finding it with adb shell settings list <secure/system/global>

Exosylver
  • 135
  • 1
  • 14