How do I request root access in Android?

后端 未结 2 1059
夕颜
夕颜 2020-11-28 23:08

I need to get root access for rooted devices, and I was wondering how I can request root access. I need the access for the file system. Thanks a lot.

相关标签:
2条回答
  • 2020-11-28 23:32

    WARNING

    THIS METHOD IS NO LONGER VALID From 5.0

    Most root devices use Superuser or SuperSU, if you wanna root ability in your app, you should claim superuser permission in your app manifest.

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

    More detailed information, you should check HOW-To SU by Chainfire (The author of SuperSU) and look into the example source libsuperuser(https://github.com/Chainfire/libsuperuser)

    0 讨论(0)
  • 2020-11-28 23:42

    Just exec the command su and within that Process you have root priviliges:

    Process p = Runtime.getRuntime().exec("su");
    

    See this blog post for full example.

    0 讨论(0)
提交回复
热议问题