Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Using Categories in Monkey

Tags:

android

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

The relevant portion of my manifest file looks like this:

   <application android:icon="@drawable/icon" android:label="@string/app_name" android:name="MyApp" android:debuggable="true" android:allowBackup="false" android:testOnly="false">
        <activity android:name="MyLauncherActivity" android:label="@string/app_name" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="MyMainActivity" android:label="@string/app_name" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="none" />
                <category android:name="android.intent.category.MONKEY" />
            </intent-filter>
        </activity>

I run the application on my phone to make sure it is working then I enter this at the command line:

adb shell monkey -p my.full.package.path -vvv 3

It works just fine.

But this doesn't work:

adb shell monkey -p my.full.package.path -c intent.CATEGORY_LAUNCHER -vvv 3

and yields the following output:

:Monkey: seed=0 count=3

:AllowPackage: myapp.full.package.path

:IncludeCategory: intent.CATEGORY_LAUNCHER

// Warning: no activities found for category intent.CATEGORY_LAUNCHER

** No activities found to run, monkey aborted.

And trying some variants also didn't work:

    :Monkey: seed=0 count=3

:AllowPackage: my.full.package.path

:IncludeCategory: CATEGORY_MONKEY

:IncludeCategory: intent.CATEGORY_MONKEY

:IncludeCategory: android.intent.MONKEY

:IncludeCategory: android.intent.category.MONKEY

:IncludeCategory: MONKEY

// Warning: no activities found for category CATEGORY_MONKEY

// Warning: no activities found for category intent.CATEGORY_MONKEY

// Warning: no activities found for category android.intent.MONKEY

// Warning: no activities found for category MONKEY

** No activities found to run, monkey aborted.

How do I specify categories

like image 853
tjb Avatar asked Oct 29 '11 14:10

tjb


People also ask

What is intent category?

Standard categories are defined in the Intent class as CATEGORY_name constants. The name assigned here can be derived from those constants by prefixing " android. intent. category. " to the name that follows CATEGORY_ .

What is category launcher?

category -- Gives additional information about the action to execute. For example, CATEGORY_LAUNCHER means it should appear in the Launcher as a top-level application, while CATEGORY_ALTERNATIVE means it should be included in a list of alternative actions the user can perform on a piece of data.

How do I run Monkeyrunner on Android?

Running monkeyrunner You do both by invoking the monkeyrunner command which is found in the tools/ subdirectory of your SDK directory. If you provide a filename as an argument, the monkeyrunner command runs the file's contents as a Python program; otherwise, it starts an interactive session.


1 Answers

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.

like image 123
James Becwar Avatar answered Oct 18 '22 05:10

James Becwar