I have an accessibility service which has to open an activity when some conditions are met.
The code to open the activity is this:
Intent intent = new Intent(WindowChangeDetectingService.this, OpenActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
I've tried many other flags like FLAG_ACTIVITY_BROUGHT_TO_FRONT or FLAG_ACTIVITY_REORDER_TO_FRONT, and set action as: ACTION_PICK_ACTIVITY, but it doesn't start the activity.
I'm using a Xiaomi Mi9T and it doesn't work, but a colleague uses a Huawei and it does work for him, and on the emulator (Pixel phone) it works too. How can I fix this for the Xiaomi devices?