在Android上执行shell命令 [英] Executing shell command on Android
问题描述
我想知道Cordova或Cordova的任何插件是否允许我在Android shell中执行命令?类似于在连接到手机的台式机上执行 adb shell myCoolBinary -doThisStuff
。
I'm wondering if Cordova or any plugin for Cordova enables me to execute a command in the android shell? Similar to doing adb shell myCoolBinary -doThisStuff
on a desktop machine connected to the phone.
教程如何使用Cordova cli桌面应用程序,这绝对不是我在寻找。我想在手机上执行命令。
Googling for this only returns tutorials for how to use the Cordova cli desktop application, which absolutely NOT what I'm looking for. I want to execute commands ON the phone.
推荐答案
我最终编写了自己的插件。
我主要把它从另一个问题,是关于从你的Android应用程序执行根shell执行。
I ended up writing my own plugin. I mostly put it together from another question that was about doing root shell executes from within your android app. I just adapted it to cordova.
我没有时间做这个好的,所以这里是一个提示:
https://gist.github.com/PTS93/d78ee885ee0c2f74892434008a953f8c
I don't have the time to make this nice so here is a gist: https://gist.github.com/PTS93/d78ee885ee0c2f74892434008a953f8c
只需使用此插件模板的文件替换文件:
https://github.com / don / cordova-plugin-hello
Just replace the files with the files from this plugin template: https://github.com/don/cordova-plugin-hello
您可以在cordova应用程式中呼叫:
You can then in your cordova app call this:
shell.execute("your shell command", success, failure);
这篇关于在Android上执行shell命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!