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);
Jagan
  • 672
  • 1
  • 11
  • 35
  • can any one help me i'm stuck in this for 2 days – Jagan Sep 11 '12 at 07:58
  • Can you provide us with the content where you're running the original question code? (Intent handler, maybe?) – tinsukE Sep 12 '12 at 16:54
  • @tinsukE i am geting new alarm from the server when they all one new alert i call this method – Jagan Sep 13 '12 at 06:10
  • @tinsukE 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 lock – Jagan Sep 13 '12 at 06:14

2 Answers2

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.

dd619
  • 5,354
  • 7
  • 29
  • 56
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();
}
Jagan
  • 672
  • 1
  • 11
  • 35