명령창말고 안드로이드 소스에서 shell명령어를 쓰고자 하는데 안먹히네요..
시도하고자 하는 것은 특정 패키지명을 얻어와 앱을 강제 종료하는 것입니다.
아래소스처럼 했는데 먹히지가 않네요.. 원인이 뭘까요?
Runtime runtime = Runtime.getRuntime();
Process process = null;
try {
String cmd = "am force-stop 패키지명";
process = runtime.exec(cmd);
} catch (Exception e) {
e.fillInStackTrace();
Log.e("Process Manager", "Unable to execute top command");
}
출처: http://mobileandlife.tistory.com/entry/안드로이드-소스에서-shell-명령어-실행하기 [모바일 보물창고]