如何从Android代码运行ADB Shell命令? [英] how to run adb shell commands from android code?

查看:1994
本文介绍了如何从Android代码运行ADB Shell命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Java代码运行以下命令:

I want to run these commands from java code:

adb shell settings put secure location_providers_allowed gps, wifi,network 

a broadcast -a android.location.GPS_ENABLED_CHANGE --ez enabled true

请帮助我如何从Android代码运行.

Please help me how to run from Android code.

推荐答案

您可以使用此方法运行命令

You can use this method to run commands

private void runShellCommand(String command) throws Exception {
    Process process = Runtime.getRuntime().exec(command);
    process.waitFor();
}

这篇关于如何从Android代码运行ADB Shell命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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