I would like to be able to launch my app after installation with ant just as happens when pressing the run
button in eclipse.
Is there an existing ant task after creating a project on the command line or is there a command I could execute with ant?
The Android ANT SDK enables developers to connect Android apps to ANT devices. It is provided to allow you to connect to proprietary devices and build complex topologies utilising advance ANT features such as background scanning and phone-phone applications.
The ANT is a task designed to test three attentional networks in children and adults: alerting, orienting, and executive control. Efficiency of the alerting network is examined by changes in reaction time resulting from a warning signal.
Using the command provided by Navin I was able to create this ant target:
<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="-n"/>
<arg value="{package.name}/{activity}"/>
</exec>
</target>
On the command line I execute:
ant debug install run
And it all works swimmingly.
EDIT
As WarrenFaith helpfully pointed out in the comments {activity}
should be the class name of main activity with a .
prefix.
So a complete example of the value of the last arg would be
org.package.name/.MyCustomActivity
Generally, copy following target to your build.xml or custom_rules.xml. Note that in custom_rules.xml (if it doesn't yet exist) you need to wrap this in a element.
<target name="start">
<xpath input="AndroidManifest.xml"
expression="/manifest/@package"
output="manifest.package" />
<xpath input="AndroidManifest.xml"
expression="/manifest/application/activity[intent-filter/action/@android:name='android.intent.action.MAIN']/@android:name"
output="manifest.main" />
<echo level="info">Restart main activity ${manifest.package}/.${manifest.main}</echo>
<exec executable="${android.platform.tools.dir}/adb">
<arg value="shell"/>
<arg value="am"/>
<arg value="start"/>
<arg value="-S"/>
<arg value="-a"/>
<arg value="android.intent.action.MAIN"/>
<arg value="-n"/>
<arg value="${manifest.package}/.${manifest.main}"/>
</exec>
</target>
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