If you press the home button on an Android device and then you call startActivity()
it will silently fail and there doesn't seem to be a way to check when it fails. For example:
@Override
protected void onStop() {
super.onStop();
Handler hndlr = new Handler();
Runnable t = new Runnable() {
public void run() {
startActivity(new Intent(getApplicationContext(), SomeOtherActivity.class)); //this silently fails, no error, nothing
}
};
hndlr.postDelayed(t, 1000);
}
Is there a way to check if it fails to start the activity? I don't intend to start any activity in the background, I just need to know when it fails. Please note that this only happens when you press the home button, I'm actually not sure if this is just an Android bug (I'm testing on Android 11). Thanks!