Android examples for Android OS:Shell
switch User in Shell
//package com.java2s; import java.io.DataOutputStream; import java.io.IOException; public class Main { public static void switchUser(String id) { Process p;/*from w w w . j a va 2s.c o m*/ try { p = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(p.getOutputStream()); os.writeBytes("am switch-user " + id + "\n"); os.writeBytes("exit\n"); os.flush(); } catch (IOException e) { e.printStackTrace(); } } }