10

I have tried multiple commands to close the app from App switcher but didn't through it. I even don't know if there is ány adb command which is persist to close the app from the app switcher. I more Googled for the same and even went through Android but no luck. Does anyone know about this, how to tackle? Kindly suggest our valuable inputs. Thanks in advance

Eitel Dagnin
  • 959
  • 4
  • 24
  • 61
Vaibhav Joshi
  • 211
  • 2
  • 4
  • 9
  • I believe this is a duplicate of http://stackoverflow.com/questions/3117095/stopping-an-android-app-from-console and that what you are looking for might be – Lasse Nov 25 '15 at 04:57
  • Okay, the question is same but still I didn't get the exact answer. The one you refer from that, "adb shell pm clear com.my.app.package" commands gets sign out as well, also "adb shell am force-stop com.my.app.package" not take out the app from recent open app list(app switcher). I just want to take out my app from recent app list(which shows in app switcher). ....Is there be specific command which can at least tap on cross icon on the app which is opened in app switcher? – Vaibhav Joshi Nov 25 '15 at 06:13

6 Answers6

15

Finally, I got the answer when I tried combining multiple commands:

  1. Open the app switcher

    adb shell input keyevent KEYCODE_APP_SWITCH
    
  2. Select or navigate to the next app in the app switcher

    adb shell input keyevent 20
    ...
    

    (run the above command again for each app down the list)

  3. Remove the app from open app list

    adb shell input keyevent DEL
    

And you are done :-) the app gone out of your open apps list.

Ky -
  • 30,724
  • 51
  • 192
  • 308
2

android 5.0 and more

open recent apps

adb shell input keyevent KEYCODE_APP_SWITCH

select app

adb shell input keyevent KEYCODE_DPAD_DOWN

clear from recent apps

adb shell input keyevent DEL

2

Thanks to @rilwan for the answer, below command worked for me: First enter into adb shell then execute:

$ adb shell
$ input keyevent KEYCODE_APP_SWITCH && input swipe 522 1647 522 90

or execute at once

$ adb shell input keyevent KEYCODE_APP_SWITCH && input swipe 522 1647 522 90
HackRx
  • 198
  • 2
  • 14
1
  1. Get stack id
    adb shell dumpsys activity recents

##########result example RecentTask 0

RecentTaskInfo #0:
    id=170 userId=0 hasTask=true lastActiveTime=102664977
    baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x
10200000 cmp=com.android.vending/.AssetBrowserActivity }
    baseActivity={com.android.vending/com.android.vending.AssetBrowserActivity}
    topActivity={com.android.vending/com.google.android.finsky.activities.MainActivity}
    origActivity={com.android.vending/com.android.vending.AssetBrowserActivity}
    realActivity={com.android.vending/com.google.android.finsky.activities.MainActivity}
    isExcluded=false activityType=standard windowingMode=fullscreen supportsSplitScreenMultiWindow=t
rue supportsMultiWindow=true
    taskDescription { colorBackground=#fffafafa colorPrimary=#ffffffff iconRes=/0 iconBitmap=false r
esizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION minWidth=-1 minHeight=-1 colorBackgroundFloating=#f
fffffff }
    lastSnapshotData { taskSize=Point(1080, 2400) contentInsets=Rect(0, 91 - 0, 126) bufferSize=Poin
t(1080, 2400) }
  1. Remove stack id 170 (play store)
    adb shell am stack remove 170
RusArtM
  • 1,116
  • 3
  • 15
  • 22
Babbo Natale
  • 81
  • 1
  • 3
0

Here are some tips-

  1. Open recent apps-

adb shell input keyevent KEYCODE_APP_SWITCHER

  1. Tap the cross X or close all . Depends on your system UI you need to navigate to it and press enter. For me below worked, you can find what works for your device using up,down,tab KEYEVENTs.

adb shell input keyevent KEYCODE_DPAD_DOWN

adb shell input keyevent KEYCODE_ENTER

Community
  • 1
  • 1
Rilwan
  • 2,251
  • 2
  • 19
  • 28
  • This command I tried on my side but seems doesn't response from system side. I couldn't get the reason why it does not worked here. because rest adb commands are working properly. – Vaibhav Joshi Dec 01 '15 at 11:23
  • Even I tried using with the suggested alternatives but still :-( – Vaibhav Joshi Dec 01 '15 at 11:30
  • which command is not working for you ? `APP_SWITCHER` or the below? and which android version you are currently working on? – Rilwan Dec 02 '15 at 03:24
  • The below commands, adb shell input keyevent KEYCODE_DPAD_DOWN adb shell input keyevent KEYCODE_ENTER, Tried with other combinations like, TAB, UP, DOWN, – Vaibhav Joshi Dec 02 '15 at 06:35
  • So app_switcher command is working ? if yes, then you have to see what is the combination to reach close button. – Rilwan Dec 02 '15 at 07:26
0
#get apps
dumpsys window windows | grep -P 'topApp.* u0 ([^/]+)' | grep -P '(?<= u0 )[^/]+' | xargs -l am force-stop
walkman
  • 1,743
  • 2
  • 10
  • 10