2

I can start the monkey on Android with an adb shell using the following command: adb shell monkey --ignore-crashes -p com.teslacoilsw.launcher 200 -v 1

However, I would like to know if it's possible to start the monkey from an Android app. I tried this, but it doesn't seem to work:

Process p = Runtime.getRuntime().exec("monkey --ignore-crashes -p com.teslacoilsw.launcher 200 -v 1");

No error is thrown, it just sits there.

Any ideas? Thanks!

maciekjanusz
  • 4,702
  • 25
  • 36
Shane Smiskol
  • 952
  • 1
  • 11
  • 38
  • First of all, `monkey` and `monkeyrunner` are not the same thing. Second, that's an interesting question, [this answer](http://stackoverflow.com/a/22985070/4191629) gives a clue that it might be that running this command from inside the app doesn't have necessary privileges to execute monkey. That would make sense, since monkey tries to send events to all packages installed on the device – maciekjanusz Nov 28 '16 at 01:22
  • I've approved the edit to change it to monkey, didn't know there's a difference, sorry! It looks like this is unlikely according to that answer, I was really wanting to add that as a fun feature to my app! – Shane Smiskol Nov 28 '16 at 01:28

1 Answers1

-1

Yes it can work , You need to install app as system app ,

try 
{
 Runtime.getRuntime().exec("monkey -p com.android.email -v 500");
} 
catch (IOException e) 
{
 // TODO Auto-generated catch block
}

Permissions : In AndroidManifest.xml

//ADD THESE TWO LINES IN YOUR MENIFEST .
android:sharedUserId="android.uid.system"   >
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>