【问题标题】:Running chmod from my application doesn't work after running su运行 su 后从我的应用程序运行 chmod 不起作用
【发布时间】:2012-03-07 02:28:18
【问题描述】:

我的主要目标是在 Android 应用程序中运行类似下面的内容:

$(normal mode)su
#(root mode) chmod 777 <some file>

但这里的问题是,一旦 shell 从 $ 更改 --> # chmod 命令不起作用。

实现此目的的另一种方法是制作一个 shell 脚本,将其放在 Android /data 目录中,然后手动运行它。但是如何在 Android 应用程序中运行它,确保当 shell 更改 ($--> #) 时功能保持不变?

另一种方法是使用脚本管理器应用程序运行我的脚本。

【问题讨论】:

    标签: android android-scripting


    【解决方案1】:

    试试这个

    Process suProcess = Runtime.getRuntime().exec("su");
    
        DataOutputStream os = 
            new DataOutputStream(suProcess.getOutputStream());
    
       **strong text**
        for (String Command : /*your commands*/)
        {
          os.writeBytes(Command + "\n");
          os.flush();
        }
    
        os.writeBytes("exit\n");
        os.flush();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 2013-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多