I tried adb command through java code, but it didn’t work.
Tried this in ADB command - adb shell am start -S com.android.settings/.Settings\$DeviceAdminSettingsActivity, it works well while performing it through command prompt, but fails when we run through java code.
public void openAdminSettings() { // for MAC. for Windows update accordingly
try {
String[] cmd = new String[]{"sh", "-c", "start_adb_shell_command_here"};
ProcessBuilder pb = new ProcessBuilder(cmd);
Process process = pb.start();
final Scanner in = new Scanner(process.getInputStream());
Thread t = new Thread() {
public void run() {
while (in.hasNextLine())
System.out.println(in.nextLine());
}
};
t.start();
PrintWriter writer = new PrintWriter(process.getOutputStream());
sleep(3); // just wait little bit for sure
writer.write("here_is_shell_command \n");
writer.write("here_is_shell_command_if_needed \n");
writer.write("quit \n");
writer.flush();
sleep(1); // for sure little
process.destroy();
} catch (Exception e) {
e.printStackTrace();
}
}
How about opening settings on ipad through MAC ?