Before saying that this is a duplicate, it is not as the previous answers have not helped me.
So I was trying to incorporate some monkey testing on an emulator to find bugs in my code. But, I have an issue with the monkey leaving my application and entering to home screen.
Therefore, I found --pct-syskeys 0 and --pct-appswitch 0 and thought that they could help me remove this problem. But they don't. Currently I'm running the following command:
adb shell monkey -p my.package.app -v -v --throttle 300 --pct-syskeys 0 --pct-appswitch 0 5000
Yet, the monkey keeps going home anyway. In the logs, I can see that the monkey has done the following input to the system, after which the home page is entered:
:Sending Key (ACTION_DOWN): 3 // KEYCODE_HOME
:Sending Key (ACTION_UP): 3 // KEYCODE_HOME
Sleeping for 300 milliseconds
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] cmp=com.google.android.apps.nexuslauncher/.NexusLauncherActivity } in package com.google.android.apps.nexuslauncher
How do I stop KEYCODE_HOME from triggering in the monkey?
Tried: --pct-syskeys 0 --pct-appswitch 0
to force monkey to not trigger system keys (such as home) and not to launch other packages.
Expected: App staying on screen, never going home.