Hello I'm working on VoIP feature for the app and I'm trying to handle cases when app is killed. My idea is to go with FCM notification and run activity which will show user incoming call screen. It works as expected when phone is unlocked but not the case when phone is locked.

I tried this :

  if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1) {
      setShowWhenLocked(true);
      setTurnScreenOn(true);
    }else{
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

I tried adding flags to activity in manifest but no luck. Also I tried putting it before super.onCreate() after on super.onCreate() and also after setContentView() but no luck.

I just want same behaviour as with Viber and WhatsApp. But currently I'm out of ideas how they do it.

I tested above code on PocoPhone F1 with latest update.

Related posts

Recent Viewed