Executing shell command on Android

╄→гoц情女王★ 提交于 2019-12-12 09:16:54

问题


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.

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.


回答1:


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.

I don't have the time to make this nice so here is a gist: https://gist.github.com/PTS93/d78ee885ee0c2f74892434008a953f8c

Just replace the files with the files from this plugin template: https://github.com/don/cordova-plugin-hello

You can then in your cordova app call this:

shell.execute("your shell command", success, failure);


来源:https://stackoverflow.com/questions/26875701/executing-shell-command-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!