I want to click on lockscreen to count - android

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);

Related

How to remove the KEEP_SCREEN_ON flag from an opened activity on Android

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?

show popup window on lock screen

I have implemented a caller ID feature where when the screen is locked it should open the lock and show the popup with the name of the person calling.
this is the code i've added in the onCreate() of the PopupActivity.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
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);
I've also added the permissions
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
This works fine when the phone is not password/pattern protected.However it shows a black background to the popup window when the device is password/pattern protected disabling the user from attending/rejecting the call.
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 |PixelFormat.TRANSLUCENT);
This seems to be working for me

Unable to unlock screen pattern/pin lock on notification arrival in Android app

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

Android activity over lock screen specifically

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);

How to launch the app from the start when started from home button

I'm creating an application that uses alarms.
That's how I start alarm activity (in broadcast receiver)
Intent myIntent = new Intent(context, AlarmActivity.class);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(myIntent);
When alarm activity is closed, and the application is started again from home button, this activity is launched each time instead of my splash screen, and I have to remove last launched apps from recent apps menu, only then the splash screen is started when the application is launched.
By the way, the above flags are needed to unlock the screen if locked when the alarm is fired, and I have this in my alarm activity:
#Override
public void onAttachedToWindow() {
this.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);
}
Any one has an idea?

Categories

Resources