Run Android Application from Command Line
2013-01-16 15:03
423 查看
Sometime, we want to start the android application program from command line (Android Shell). Before, we usually clicking on the icon at application folder to run our program. So, there is an alternative way to run the program.
We use the Android Shell and issue am command to brought up the program. below is an example to do that.
1. Make sure that android emulator is running
2. Enter the shell with issuing command at command shell (prompt): adb shell
3. Issue am command. am command syntax is as follow :
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>
for example we have android program with Manifest like below:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.iftitah.android.contact">
<application android:icon="@drawable/icon">
<activity class=".Contact" android:label="@string/app_name">
<intent-filter>
<action android:value="android.intent.action.MAIN" />
<category android:value="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
.
.
</manifest>
To run the code issue command like this (in one line):
am start -a android.intent.action.MAIN -n
com.iftitah.android.contact/com.iftitah.android.contact.Contact
ok, Have a nice try!
We use the Android Shell and issue am command to brought up the program. below is an example to do that.
1. Make sure that android emulator is running
2. Enter the shell with issuing command at command shell (prompt): adb shell
3. Issue am command. am command syntax is as follow :
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>
for example we have android program with Manifest like below:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.iftitah.android.contact">
<application android:icon="@drawable/icon">
<activity class=".Contact" android:label="@string/app_name">
<intent-filter>
<action android:value="android.intent.action.MAIN" />
<category android:value="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
.
.
</manifest>
To run the code issue command like this (in one line):
am start -a android.intent.action.MAIN -n
com.iftitah.android.contact/com.iftitah.android.contact.Contact
ok, Have a nice try!
相关文章推荐
- [Android Tips] 16. Update Android SDK from command-line
- Run an Oracle Xellerate Task Scheduler from the Command-Line
- [Node] Run Local DevDependencies from the Command Line with npx
- tools - scalatests run from command line and sc...
- Run iOS Simulator from the Command Line (runsim)
- Java: How to compile and run Java application in command line(在命令行中编译运行java程序)
- Visual C# 2010 Recipes A Problem-Solution Approach 代码一 —— Create a Console Application from the Command Line
- Managing Projects from the Command Line(android官网文档)
- Xcode4: Running Application Tests From The Command Line in iOS
- 使用命令行工具管理Android项目(Managing Projects from the Command Line)
- How to run FTE and FTE from command line
- Cannot checkout from svn: Cannot run program "svn"和 Can't use Subversion command line client:svn
- Developing android applications from command line
- [转]How do I run msbuild from the command line using Windows SDK 7.1?
- TestNG - How to run TestNG from command line successfully
- OpenCV编译错误:/usr/local/lib/opencv_core.so.3.1:error adding symols: DSO missing from command line
- How to start a Windows CE emulator from the command line
- Import data in a Lookup Definition from the command-line
- 10 Ways to Generate a Random Password from the Command Line
- qt opencv编译错误 /usr/local/lib/libopencv_imgcodecs.so.3.1:-1: error: error adding symbols: DSO missing from command line