There is a background service that is listened to by the Broadcast server. When a call comes from the server, the method is triggered:
CallActivity1.start(this, qbrtcSession.getConferenceType(), qbrtcSession.getOpponents(), qbrtcSession.getUserInfo(), Consts.CALL_DIRECTION_TYPE.INCOMING); Where CallActivity1 is one of the application activities, but not the main one. She accepts:
public static void start(Context context, QBRTCTypes.QBConferenceType qbConferenceType, List<Integer> opponentsIds, Map<String, String> userInfo, Consts.CALL_DIRECTION_TYPE callDirectionType){ Intent intent = new Intent(context, CallActivity1.class); intent.putExtra(Consts.CALL_DIRECTION_TYPE_EXTRAS, callDirectionType); intent.putExtra(Consts.CALL_TYPE_EXTRAS, qbConferenceType); intent.putExtra(Consts.USER_INFO_EXTRAS, (Serializable) userInfo); intent.putExtra(Consts.OPPONENTS_LIST_EXTRAS, (Serializable) opponentsIds); if (callDirectionType == Consts.CALL_DIRECTION_TYPE.INCOMING) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } context.startActivity(intent); } And it is written in onCreate:
KeyguardManager.KeyguardLock lock = ((KeyguardManager) getSystemService(Activity.KEYGUARD_SERVICE)).newKeyguardLock(KEYGUARD_SERVICE); PowerManager powerManager = ((PowerManager) getSystemService(Context.POWER_SERVICE)); PowerManager.WakeLock wake = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG"); lock.disableKeyguard(); wake.acquire(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); According to my logic, when you call, the activity window should always open, it almost works that way, but alternately. When the screen is unlocked, ALWAYS starts the activity, sometimes when screen_off, and if the keyguard is still on the screen_off, it never works at all, or it can appear and close in a moment.
Step-by-step execution showed that as soon as the activity appeared, onStop immediately worked, and why it is so unknown.