2

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:

  • On Android Marshmallow (6) only
  • When key guard lock is set ON

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:

  • FLAG_DISMISS_KEYGUARD
  • FLAG_SHOW_WHEN_LOCKED

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!

Nom1fan
  • 846
  • 2
  • 11
  • 27

2 Answers2

2

I have three suggestions for you to try, (not sure if they will work), but they are worth a try.

  1. try to add these flags:

    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    
  2. 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).

  3. 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_ERROR
    that 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.

Community
  • 1
  • 1
Jhonny
  • 457
  • 3
  • 7
  • Hi! Thanks for your response. I will definitely go on ahead to try your suggestions. One thing I might have neglected to mention is that I need both my view and the native view to be touchable. Otherwise if for example only my view is touchable, the user cannot answer calls! Which is of course very bad. I will try and update later. Thanks. – Nom1fan Jun 17 '16 at 13:34
  • i will be glad to get an update whether it was helpful for the solution. – Jhonny Jun 20 '16 at 13:21
  • Hi Jhonny, we tried all combinations of TYPE_SYSTEM_ERROR as well as TYPE_SYSTEM_ALERT, and it simply did not make a difference on Android 6 with key guard on. Somehow TrueCaller were able to get above the key guard and even above the incoming call popup. Still do not know how they are doing it. – Nom1fan Jun 21 '16 at 11:46
  • did you try putting a delay, I think maybe this is the key to wanted behaviour. – Jhonny Jun 22 '16 at 19:24
  • Yes we tried with different delays as well, but it didn't help. We are currently paying an external solutions company and they are working hard on this. Will update if they find a solution. – Nom1fan Jun 26 '16 at 14:35
  • Ok solved. Thank you very much for answering. Eventually the problem was we didn't add the TYPE_SYSTEM_ERROR in the correct place (during construction) but after the layout was already inflated. Now we added in the right place and it works great. – Nom1fan Jun 27 '16 at 12:55
  • Oh two things here that were misunderstood. first, I thought that you understood where to add this flag, i'll fix the answer, so it will be more clear for others. secondly i thought that you understand that Dror sent me to help you here, I'm Jhonny the CTO of GRapps Mobile apps development company (http://grapps.io), you talked with him and asked for our input on this issue, anyway, glad you worked it out and hope that it is working for you now. feel free to contact us in the future if you need our assistance in a development. – Jhonny Jun 27 '16 at 15:08
  • Where do you add `LayoutParams.TYPE_SYSTEM_ERROR`? I simply show the standoutwindow using the static show function like so: `StandoutWIndow.show(context, , )`. Where do I add `LayoutParams.TYPE_SYSTEM_ERROR`? – Metal Nov 29 '16 at 11:13
  • If I'm supposed to add it in Windows file, where exactly? I can only add it after inflating my layout. – Metal Nov 29 '16 at 12:01
  • 7 years too late, I'm sorry I somehow missed your comment @Metal, there were no notifications. Hope you solved it eventually :) – Nom1fan Jul 14 '22 at 13:51
1

Hi i have the same problem ... i'm trying to make an app that popup an activity over incoming & outgoing call...

my app work well except in android 6 & when the "KEYGUARD" is active.

i tried some method that could help you to find solution

i tried to use window manager with (TYPE_SYSTEM_ERROR) and inflate layout to show screen over incoming call it successfully worked & show the layout over system call screen android 6 but i found another problem with that..

this solution work fine just when the keyguard is not secured by pattern lock or pass lock...if the keyguard work with swipe to unlock & it doesn't have any lock pattern , the solution work fine but if the keyguard has any model of lock type, the custom activity screen will show over the system call screen again but activity's code such as clicklistener or button codes wont work at all ...

BTW i found some app that its exactly what you & i try to make you can find it here : Caller Screen OS9 ID Themes

i hope this could help you.

please update if you find solution

sorry for my poor English

m.r.davari
  • 164
  • 1
  • 10
  • Thanks for answering. I am not sure why you are experiencing that. We also eventually solved using TYPE_SYSTEM_ERROR and we are not experiencing what you describe with clicklisteners not working. – Nom1fan Jun 27 '16 at 12:56
  • @Nom1fan i don't know too ...my app work fine except in android 6 & i work fine in android 6 without secure keyguard... I have 2 small question 1: did you use service or activity for popup window over incoming call?! 2: did you succeed in android 6 with secure keyguard? can you post part of your code please Thanks Friend – m.r.davari Jun 28 '16 at 10:56
  • 1. I use a service that uses the WindowManager. 2. You can see the code in the answer I accepted above. It's the same code as in my application. – Nom1fan Jun 28 '16 at 13:08
  • @Nom1fan Thanks for answering.I'm using same code... I will update if i find way to solve this problem – m.r.davari Jun 28 '16 at 16:57
  • Where do you add `LayoutParams.TYPE_SYSTEM_ERROR`? I simply show the standoutwindow using the static show function like so: `StandoutWIndow.show(context, , )`. Where do I add `LayoutParams.TYPE_SYSTEM_ERROR`? – Metal Nov 29 '16 at 11:13