Trying to show my Overlay activity over device lock screen - Its Working fine. The problem when my phone ringing | Alarm ringing that time I can see the overlay only. Cancel my overlay then only i can see.. how to avoid that
My code for display activity
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
Related
I'm opening an activity with the following flags
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_FULLSCREEN);
Then later on, I want the screen to be able to time out and to turn off automatically.
I tried to remove the flag like this
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
But it doesn't seem to have any effect. Is there a way to remove this flag dynamically on a displayed activity?
I'm trying to open the activity on lock screen when I receive the notification form twilio. But I'm facing issue as it called onDestroy method when screen is locked on call receiving and it doesn't open the required activity.
I tried many solution but none of them worked.
I also tried following code to open activity on Lock screen but it doesn't work.
Window window=getWindow();
window.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);
I'm working on VOIP application and recently encountered a problem. Some devices are not waking up when screen is locked and app is in background. I've made some tests and found out that:
If app is closed with back button(task destroyed) then screen was locked and startActivity() is called - the screen is unlocked and activity works fine
If app wasn't started in a while(task wasn't created yet) then screen was locked and startActivity() is called - the screen is unlocked and activity works fine
If app was in foreground then screen was locked and startActivity() is called - the screen is unlocked and activity works fine
If user pressed the HOME button, thus putting the task in background and then screen was locked and startActivity() is called - IT DOESN'T WORK, the screen is off and activity's onCreate is not called
So, I guess it's somehow relevant with home button or the fact that application was in background when screen gets locked. The app calls startActivity() when firebase message received or JNI triggered some callbacks
Here is how I unlock the screen:
if (powerManager != null) {
wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK
| PowerManager.ACQUIRE_CAUSES_WAKEUP, "App:wakeuptag");
wakeLock.acquire(1000 * 60);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
setShowWhenLocked(true);
setTurnScreenOn(true);
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);
} else {
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);
}
And here is how I start the activity:
Intent intent = new Intent(context, VCEngine.appInfo().getActivity(ActivityType.CALL));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_NO_ANIMATION);
if (!(context instanceof Activity)) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mIsCallFromBackground.set(!AppUtils.isAppOnForeground());
}
intent.putExtra(
context.getString(R.string.extra_conference_join_or_create),
msg);
intent.putExtra(context.getString(R.string.extra_is_audio_call), isAudioCall);
intent.putExtra("isConference", isConference());
context.startActivity(intent);
I am new in android and also new on stackoverflow.
I am making an app in which i need a count button on lock screen. actully when i touch the screen it counts increase and after unlock phone it show the total count. how it possible ?
requestWindowFeature(Window.FEATURE_NO_TITLE); // 타이틀화면도 없이 전체화면으로 실행
getWindow().addFlags( WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
setContentView(R.layout.activity_lock_screen);
I am making an Android hybrid application in which my requirements are that as soon as a notification arrives, my app should open and disable all locks. I tried using KeyguardManager(deprecated) but it's working on some devices only. Basically below Lollipop only.
Now I am using this piece of code to achieve the desired result but all in vain.
I have seen many posts regarding the same issue everywhere. FLAG_DISMISS_KEYGUARD is suggested as a replacement for KeyguardManager,
but this is not working for me.
((Activity) mContext).getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
Flag dismisse full screen, flag show when local, flag dismisse anoymous input method
Irish of.
Is