【问题标题】:Executing mount command in Android device via application通过应用程序在 Android 设备中执行挂载命令
【发布时间】:2016-01-24 20:11:48
【问题描述】:

我已经植根了我的模拟器安卓设备,现在想要执行以下系统调用:

mount -o rw,remount /system

我的代码是:

Runtime.getRuntime().exec( "su -c mount -o rw,remount /system" );

但它不起作用。

谢谢

【问题讨论】:

    标签: java android mount


    【解决方案1】:

    试试这个:

    Runtime.getRuntime().exec( new String[]{"su", "-c", "mount -o remount,rw /system"} );
    

    也试试这个:

    Runtime.getRuntime().exec( new String[]{"su", "-c", "mount -o remount rw /system"} );
    

    此外,您需要在 Android Manifest 中获得以下权限:

    <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
    

    【讨论】:

    • 再次感谢 Ankur Aggarwal 的帮助。我尝试使用以下命令使用字符串数组: Runtime.getRuntime().exec( new String[]{"su", "-c", "mount", "-o", "rw,remount /system"} ) ;但没有用。
    • 挂载、-o 和命令的其余部分不应以“”分隔。 "mount -o remount rw /system" 必须是字符串数组中的单个命令。我编辑了我的答案。再试一次
    猜你喜欢
    • 2013-03-30
    • 2013-04-04
    • 2017-10-25
    • 1970-01-01
    • 1970-01-01
    • 2013-07-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多