Java tutorial
//package com.java2s; import java.io.DataOutputStream; public class Main { public static void forceStopAPK(String pkgName) { Process sh = null; DataOutputStream os = null; try { sh = Runtime.getRuntime().exec("su"); os = new DataOutputStream(sh.getOutputStream()); final String Command = "am force-stop" + pkgName; os.writeBytes(Command); os.flush(); sh.waitFor(); } catch (Exception e) { e.printStackTrace(); } } }