怎么在应用运行adb命令

发布网友 发布时间:2022-04-22 22:23

我来回答

3个回答

热心网友 时间:2022-05-02 04:03

在Android中,除了从界面上启动程序之外,还可以从命令行启动程序,使用的是命令行工具am.
usage: am [subcommand] [options]
start an Activity: am start [-D]
-D: enable debugging
send a broadcast Intent: am broadcast
start an Instrumentation: am instrument [flags]
-r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
-e : set argument to
-p : write profiling data to
-w: wait for instrumentation to finish before returning
start profiling: am profile start
stop profiling: am profile stop
specifications include these flags:
[-a ] [-d ] [-t ]
[-c [-c ] ...]
[-e|--es ...]
[--ez ...]
[-e|--ei ...]
[-n ] [-f ] []
启动的方法为:
$ adb shell
$ am start -n {包(package)名}/{包名}.{活动(activity)名称}

热心网友 时间:2022-05-02 05:21

关注。在cmd中执行adb shell后就进入了设备控制了,这里用bat肯定是不行的

热心网友 时间:2022-05-02 06:56

参考下这个/* * 清除缓存 */ public static void cleanCache(String appPackageName) { Process process = null; DataOutputStream os = null; String command = ""; try { process = Runtime.getRuntime().exec("su"); os = new DataOutputStream(process.getOutputStream()); command = "rm -r /data/data/" + appPackageName + "/cache \n"; os.writeBytes(command); os.flush(); os.close(); process.waitFor(); process.destroy(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com