how to change system alarm setting text dynamic
Asked Answered
M

2

10

Hi I'm creating a app to display the count of alarm that comes from services and i've to update that when my screen is lock.

but i am getting a out put but it is not updating can any one help me

this is my output

this is a code i used for display the text in lock screen

 String message ="New alarm :"+ alarmnew.size()+"\n old alarm :"+alarmold.size();
 Settings.System.putString(this.getContentResolver(),
         Settings.System.NEXT_ALARM_FORMATTED, message);
Meson answered 11/9, 2012 at 7:15 Comment(4)
can any one help me i'm stuck in this for 2 daysMeson
Can you provide us with the content where you're running the original question code? (Intent handler, maybe?)Larissa
@Larissa i am geting new alarm from the server when they all one new alert i call this methodMeson
@Larissa and when it is lock i am not getting any update but when i unlock it and lock again it has been updated. i want to get update on the lock-screen when it is lockMeson
M
0

guys i've finally found the answer to this prob thanks to @dd619 his concept

the concept i used is that first i need to unlock the screen then update display and again lock the screen.

this is my final coding for this app

{
Context context= getApplicationContext();

KeyguardManager _guard = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock _keyguardLock = _guard.newKeyguardLock("KeyguardLockWrapper");
        //to disable
_keyguardLock.disableKeyguard();


 String message ="New alarm :"+ alarmnew.size()+"\n old alarm :"+alarmold.size();
 Settings.System.putString(this.getContentResolver(),
         Settings.System.NEXT_ALARM_FORMATTED, message);

         //to enable
 _keyguardLock.reenableKeyguard();
}
Meson answered 13/9, 2012 at 8:17 Comment(0)
D
1

for that first you need unlock the screen then update display and again lock the screen. you can lock or unlock screen by using, window.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD); and DevicePolicyManager lockNow() method.

Actually when screen locks ,your application goes to onPause() but the services of the application keeps running as they runs in background.Hence, to solve your problem you need to wakeup your application for fraction of second then update the screen and then again lock the screen.

Deprave answered 13/9, 2012 at 6:55 Comment(1)
how do i used this in coding any exampleMeson
M
0

guys i've finally found the answer to this prob thanks to @dd619 his concept

the concept i used is that first i need to unlock the screen then update display and again lock the screen.

this is my final coding for this app

{
Context context= getApplicationContext();

KeyguardManager _guard = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock _keyguardLock = _guard.newKeyguardLock("KeyguardLockWrapper");
        //to disable
_keyguardLock.disableKeyguard();


 String message ="New alarm :"+ alarmnew.size()+"\n old alarm :"+alarmold.size();
 Settings.System.putString(this.getContentResolver(),
         Settings.System.NEXT_ALARM_FORMATTED, message);

         //to enable
 _keyguardLock.reenableKeyguard();
}
Meson answered 13/9, 2012 at 8:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.