title: Running adb commands from android application
body: <p>How to run <code>adb shell am</code> commands from within an android application. I tried to run dumpheap command. <code>Process p = Runtime.getRuntime().exec("am dumpheap -n 3554 /sdcard/memory");</code>. I am getting the following error.</p>
  
  <pre><code>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)
  </code></pre>