I would like, for multiple testing purposes, start my android activity from Eclipse with specific data on the intent (e.g. extra data like a file name to load). Where in the menus can I provide this?
If your still using eclipse you probably need need to create a simple ant script with a custom task to execute the test. ADB shell has a command to start activities where you can also specify extra's
am [start|instrument]
am start [-a <action>] [-d ]
[-t <mime_type>] [-c <category> [-c <category>] ...]
[-e <extra_key> <extra_value>
[-e <extra_key> <extra_value> ...]
[-n <component>] [-D] [<uri>]
am instrument [-e <arg_name> <arg_value>] [-p <prof_file>] [-w] <component>
You would pass them like this:
am start -a android.intent.action.VIEW -c android.intent.category.DEFAULT -e foo bar -e bert ernie -n org.package.name/.MyCustomActivity
P.S. don't forget the dot before the activity.
This can be translated to an ant target which you should put in the ant script.
<target name="run">
<exec executable="adb">
<arg value="shell"/>
<arg value="am"/>
<arg value="start"/>
<arg value="-a"/>
<arg value="android.intent.action.MAIN"/>
<arg value="-e"/>
<arg value="extra_key extra_value"/>
<arg value="-n"/>
<arg value="{package.name}/{activity}"/>
</exec>
</target>
which you can execute like this: ant debug install run
How to run ant files from eclipse see:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With