博客
关于我
adb shell 启动,停止 android 应用程序
阅读量:279 次
发布时间:2019-03-01

本文共 1229 字,大约阅读时间需要 4 分钟。

ADB 启动与停止 Android 应用程序的完整指南

在 Android 开发中,ADB(Android Debug Bridge)是开发者必不可少的工具,可以用来远程控制 Android 设备。本文将介绍如何通过 ADB 启动和停止应用程序的方法。

一、ADB 启动 应用程序

通过 ADB 启动应用程序,可以直接在开发环境中测试应用程序的运行效果。以下是具体操作步骤:

步骤如下:

1. 查看应用程序包名

首先需要知道目标应用程序的包名。可以通过以下命令查看:

adb shell

在 root@android:/ # 后,输入以下命令:

cd data/data

然后输入:

ls

这样就能看到 Android 系统上安装的安装包包名,例如:

cn.com.conversant.swiftsync.android com.android.backupconfirm com.android.browser com.android.calculator2 com.android.calendar com.android.camera

2. 启动应用程序

使用 ADB 启动应用程序时,可以通过以下命令实现:

adb shell am start -n {包名}/{Activity类的类名}

其中,包名和 Activity 类的类名必须输入正确。可以通过 re-sign 工具(在最后的弹出信息框会显示出包名和 Activity 类名)获取准确信息。

例如,启动某个应用程序的特定 Activity 类:

adb shell am start -n cn.com.conversant.swiftsync.android/cn.com.conversant.swiftsync.android.main.SplashActivity

通过以上方法,可以轻松启动 Android 应用程序进行测试或调试。

二、ADB 停止 应用程序

有时候需要通过 ADB 停止正在运行的应用程序,尤其是在测试过程中需要重复使用设备时。以下是具体操作方法:

步骤如下:

1. 停止指定包名的应用程序

使用以下命令可以立即停止指定包名的应用程序运行:

adb shell am force-stop {包名}

例如,停止应用程序 cn.com.conversant.swiftsync.android 的运行,可以使用以下命令:

adb shell am force-stop cn.com.conversant.swiftsync.android

2. force-stop 命令的特点

force-stop 命令会强制停止目标应用程序,无论其当前处于哪个状态(正在运行、正在前置、正在后台等)。使用前请确保该操作不会对开发过程造成不便。

总之,通过 ADB 可以轻松地启动和停止 Android 应用程序,节省了手动安装和运行的时间,同时也为开发和调试提供了便利。

转载地址:http://yaha.baihongyu.com/

你可能感兴趣的文章
NMAP网络扫描工具的安装与使用
查看>>
NMF(非负矩阵分解)
查看>>
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>