I am using Mark Wei's incredible library StandOut in my app: http://pingpongboss.github.io/StandOut/
What I am doing is very similar to TrueCaller App
Which is displaying my own view upon an incoming call. This generally works great.
What is my problem?
On a very specific case:
Then the app's StandOut window is sent back behind the incoming call window and is not shown except for a flicker for a fraction of a second.
What have I tried?
Using both these flags together:
In addition (and separately) I tried this deprecated way:
KeyguardManager.KeyguardLock mLock;
KeyguardManager mKeyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
mLock = mKeyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
mLock.disableKeyguard();
When this also failed, I tried granting my app Administrator privileges (I won't add the whole code to do it as it's long but I did it properly) and then tried this:
devicePolicyManager.setKeyguardDisabled(deviceAdmin,true);
NOTE: I want to stress again that I know this is possible since TrueCaller App Is doing it so well and does not fail on every call. Just need help to find the right way to do it.
Thanks in advance!
I have three suggestions for you to try, (not sure if they will work), but they are worth a try.
try to add these flags:
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
try to add a delay of let's say 2 seconds before you fire the StandOut window activity to make sure it is coming after the incoming call system screen (later, if this solves the issue, reduce the delay as much as possible).
Also found this answer here, not sure if you have access to the window properties, but saw this solution:
"We were also facing similar issue that the overlay was not displayed on a device with pin lock. The solution that worked for us is below:
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mParams = new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT,
LayoutParams.TYPE_SYSTEM_ERROR,
LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
It was
LayoutParams.TYPE_SYSTEM_ERRORthat made the difference."
The question that is similar: Pop up window over Android native incoming call screen like true caller Android app
Hope that something here is helpful to you, please update if solved.
UPDATE: This was solved the issue: (adding this):
LayoutParams.TYPE_SYSTEM_ERROR
Just make sure to add this before the layout is inflated, otherwise it will do nothing.