在Android上执行shell命令

编程入门 行业动态 更新时间:2024-10-27 00:30:23
本文介绍了在Android上执行shell命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道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.

我没有时间做这个好的,所以这里是一个提示: gist.github/PTS93/d78ee885ee0c2f74892434008a953f8c

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

只需使用此插件模板的文件替换文件: github / don / cordova-plugin-hello

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

您可以在cordova应用程式中呼叫:

You can then in your cordova app call this:

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

更多推荐

在Android上执行shell命令

本文发布于:2023-10-07 14:46:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469677.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令   Android   shell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!