java - How to make your android app ask for superuser access only once? -


I am preparing my first Android app that is changing your MAC address and device hostname. However, I only want to request superuser access once.

In this way I am implementing my own commands:

  string [] cmdHost = {"su", "-c", "/ system / bin / Setprop net.hostname "+ strHostname}" Execute = Runtime.getRuntime (). Exec (cmdHost);   

Every time the user presses the button to change the hostname or MAC address, then the superuser asks again to access.

Is there any way, can I solve it? In addition, I see that some applications only implement / system / bin / sh in the SuperUser app log. Shows my complete order.

Thanks a lot!

Check out library - it supports operations like the following:

  if (RootTools.isAccessGiven ()) {/ * magic root code is here / /   

you can open the command like this

 < Code> try {list; String & gt; Output = roottool.Send shell (command); String [] commands = new string [] {command1, command2}; & Lt; String & gt; OtherOutput = RootTools.sendShell (commands); } Hold (IOException E) [Something went wrong, deal with it here}    

Comments