云飞狼舞
云飞狼舞
  • 发布:2016-12-23 17:43
  • 更新:2018-10-17 09:02
  • 阅读:2187

请教JAVA代码转换为Native.JS写法问题!

分类:Native.js

请问怎么把如下类在Native.JS怎么写?
或者说Native.JS有没有办法实现执行shell指令,进而实现模拟按键操作呢?

public class RootShellCmd  
{   
    private OutputStream os;  
    /** * 执行shell指令 * * @param cmd * 指令 */  
    public final void exec(String cmd)  
    {  
        try  
        {  
            if (os == null)  
            {  
                os = Runtime.getRuntime().exec("su").getOutputStream();  
            }  

            os.write(cmd.getBytes()); os.flush();  
        }  
        catch (Exception e)  
        {  
            e.printStackTrace();  
        }  
    }  

    /** * 后台模拟全局按键 * * @param keyCode * 键值 */  
    public final void simulateKey(int keyCode)  
    {  
        exec("input keyevent " + keyCode + "\n");  
    }  
}  
2016-12-23 17:43 负责人:无 分享
已邀请:
c***@vip.qq.com

c***@vip.qq.com

var Runtime = plus.android.importClass("java.lang.Runtime");
Runtime.getRuntime().exec("su");
var arr = ["su", "-c", "input keyevent 3"];
Runtime.getRuntime().exec(arr);

该问题目前已经被锁定, 无法添加新回复