Java tutorial
//package com.java2s; import java.io.IOException; import java.io.OutputStream; public class Main { private static Process process; private static void killProcess(String packageName) { OutputStream out = process.getOutputStream(); String cmd = "am force-stop " + packageName + " \n"; try { out.write(cmd.getBytes()); out.flush(); } catch (IOException e) { e.printStackTrace(); } } }