如何在Android应用程序中运行adb shell am
命令。我试图运行dumpheap命令。 Process p = Runtime.getRuntime().exec("am dumpheap -n 3554 /sdcard/memory");
。我收到以下错误。
java.lang.SecurityException: Requires permission android.permission.SET_ACTIVITY_WATCHER
at android.os.Parcel.readException(Parcel.java:1425
at android.os.Parcel.readException(Parcel.java:1379)
at android.app.ActivityManagerProxy.dumpHeap(ActivityManagerNative.java:3548)
at com.android.commands.am.Am.runDumpHeap(Am.java:721)
at com.android.commands.am.Am.run(Am.java:124)
at com.android.commands.am.Am.main(Am.java:81)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
at dalvik.system.NativeStart.main(Native Method)