android adb 启动activity、service,发送broadcast等操作

来源:互联网 发布:mac系统语言代码 编辑:程序博客网 时间:2024/06/03 15:08

android adb 启动activity、service,发送broadcast等操作

一、adb启动activity:

adb shellam start -n {包(package)名}/{包名}.{活动(activity)名称}

如:启动浏览器

adb shellam start -n com.android.browser/com.android.browser.BrowserActivity

二、adb关闭activity:

adb shellam force-stop {包(package)名}

如:关闭浏览器adb shellam force-stopcom.android.browser

三、adb启动service:

adb shellam startservice -n{包(package)名}/{包名}.{服务(service)名称}

如:启动自己应用中一个service

adb shellam startservice -n com.android.traffic/com.android.traffic.maniservice

四、adb卸载应用程序:

adb uninstall{包(package)名}

如:卸载浏览器adbuninstallcom.android.browser

五、adb发送broadcast:

adb shellam broadcast -a <广播动作>

如:发送一个网络变化的广播

adb shellam broadcast -a android.net.conn.CONNECTIVITY_CHANGE

六、adb端口转发:

adb shell am broadcast -a NotifyServiceStop

adb forward tcp:12580 tcp:10086

adb shell am broadcast -a NotifyServiceStart

 

0 0
原创粉丝点击