如何使用终端来运行特定的Andr​​oid应用程序? [英] How to run a specific Android app using Terminal?

查看:180
本文介绍了如何使用终端来运行特定的Andr​​oid应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了Eclipse和Android SDK了。一切都运行良好。

I installed Eclipse and Android SDK already. Everything is running fine.

我要安装的.apk文件,所以我按照说明了。但问题是,当我启动模拟器,它不会自动运行我的应用程序。

I want to install an .apk file so I follow the instruction already. But the problem is, when I start the emulator, it doesn't run my app automatically.

我想问一下,有没有在终端的命令,让我来运行特定的应用程序,我自讨苦吃?

I would like to ask, is there a command in the terminal that allow me to run the specific app that I ask for it?

感谢提前。

推荐答案

使用了上午启动命令,这是一个是一个命令行界面<一个href="http://$c$c.google.com/android/reference/android/app/ActivityManager.html">ActivityManager.使用启动活动如下面的帮助:

Use the 'am start' command, which is a is a command-line interface to the ActivityManager. Use am to start activities as shown in this help:

$ adb shell am
usage: am [start|instrument]
       am start [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
                [-c <CATEGORY> [-c <CATEGORY>] ...]
                [-e <EXTRA_KEY> <EXTRA_VALUE> [-e <EXTRA_KEY> <EXTRA_VALUE> ...]
                [-n <COMPONENT>] [-D] [<URI>]
       ...

例如,启动联系人应用程序,你可以使用

For example, to start the Contacts application you can use

$ adb shell am start -n com.google.android.contacts/.ContactsActivity

另请参见<一个href="http://www.kandroid.org/online-pdk/guide/instrumentation_testing.html">http://www.kandroid.org/online-pdk/guide/instrumentation_testing.html (可能是过时的URL的副本:<一href="http://source.android.com/porting/instrumentation_testing.html">http://source.android.com/porting/instrumentation_testing.html )的其他细节。

See also http://www.kandroid.org/online-pdk/guide/instrumentation_testing.html (may be a copy of obsolete url : http://source.android.com/porting/instrumentation_testing.html ) for other details.

要终止应用程序,你可以使用

To terminate the application you can use

$ adb shell am kill com.google.android.contacts

或更激烈的

$ adb shell am force-stop com.google.android.contacts

这篇关于如何使用终端来运行特定的Andr​​oid应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆