简体   繁体   中英

ADB Start activity name doesn't work

I dumped and logged a few things in ADB with my Galaxy Note 3. Logcat gave me following line:

    #party pause(  870): onReceive android.intent.action.ACTIVITY_STATE/th.in.siamgame.ggplay.mwcasia/resume

And another dumpfile told me that the package name is :

    th.in.siamgame.ggplay.mwcasia

I tried a few variations of my ADB Start command.

    adb shell am start -n th.in.siamgame.ggplay.mwcasia/th.in.siamgame.ggplay.mwcasia.resume

    adb shell am start -n th.in.siamgame.ggplay.mwcasia/.resume

On both of those commands also with

    -a android.intent.action.ACTIVITY_STATE

I hope you guys can help me with starting that app via ADB.

Proper syntax of the command is:

adb shell am start -n package/.activity

For example:

adb shell am start -n com.example/.ActivityName

It seems resume isn't the name of activity. You can find main activity name in the AndroidManifest.xml (if you have source code of course). It's the one with the attributes in intent filter:

<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

If you don't have source code, but have apk file, you still can find it with the aapt tool. aapt located in the <android-sdk-path>/build-tools/<version>/aapt . Start it with command aapt l -a filename.apk and you will get output like this:

N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=2)
    A: android:versionCode(0x0101021b)=(type 0x10)0xc
    A: android:versionName(0x0101021c)="1.0.1" (Raw: "1.0.1")
    A: package="com.example" (Raw: "com.example")
    E: application (line=8)
      A: android:theme(0x01010000)=@0x7f0d0022
      A: android:label(0x01010001)=@0x7f0b0000
      A: android:icon(0x01010002)=@0x7f020002
      A: android:name(0x01010003)="AppName" (Raw: "AppName")
      A: android:debuggable(0x0101000f)=(type 0x12)0x0
      E: activity (line=15)
        A: android:label(0x01010001)=@0x7f0b0000
        A: android:name(0x01010003)=".MainActivity" (Raw: ".MainActivity")
        A: android:launchMode(0x0101001d)=(type 0x10)0x2
        A: android:configChanges(0x0101001f)=(type 0x11)0xb0
        E: intent-filter (line=21)
          E: action (line=22)
            A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
          E: category (line=25)
            A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
 ... etc ...

And again you need "android.intent.action.MAIN" and "android.intent.category.LAUNCHER" . It is .MainActivity in the example.

Use the action MAIN to start your app rather than ACTIVITY_STATE. ACTIVITY_STATE is an internal system action which is only sent by the framework:

-a android.intent.action.MAIN

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM