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

Published on with 0 views and 0 comments

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

说你懂得生之微末,我便做了这壮大与你看,你说再热闹也终需离散,我便做了这一辈子与你看,你说冷暖自知,我便做了这冬花夏雪与你看,你说恋恋旧日好时光,我便做了这描金绣凤的浮世绘与你看。你说应愁高处不胜寒,我便拱手河山,讨你欢。