Android: Using Categories in Monkey

前端 未结 2 1446
暖寄归人
暖寄归人 2021-01-17 14:48

How do I use the categories option of the monkey tool?

The relevant portion of my manifest file looks like this:

   

        
相关标签:
2条回答
  • 2021-01-17 15:32

    You're really close. This worked for me:

    adb shell monkey -p com.JamesBecwar.test -c android.intent.category.LAUNCHER -vvv 3
    

    I think the problem is that you need to include the Launcher too, because if you don't monkey can't start the program. Don't worry you can put more then one -c param. For example you could do:

    adb shell monkey -p com.JamesBecwar.test -c android.intent.category.LAUNCHER -c android.intent.category.MONKEY -vvv 3
    

    and it should work.

    0 讨论(0)
  • 2021-01-17 15:43

    As far as I can understand by looking at the Monkey source code is that the -c argument stands for "main-category", it will only work in combination with a main-action. That the -c/main-categories criteria will only work when the monkey tries to start the app with "Implicit Intents" and not "Explicit Intents" within the app.

    <intent-filter>
        <action android:name="android.intent.action.MAIN" /> 
        <category android:name="android.intent.category.MONKEY" />
    </intent-filter>
    

    https://android.googlesource.com/platform/development/+/master/cmds/monkey/src/com/android/commands/monkey/Monkey.java

    0 讨论(0)
提交回复
热议问题