How to run adb shell am
commands from within an android application. I tried to run dumpheap command. Process p = Runtime.getRuntime().exec("am dumpheap -n 3554 /sdcard/memory");
. I am getting the following error.
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)
You may have to give required permission in Manifest file. Though from docs it looks like it is only for debug purpose.
You can view the details here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.