Search code examples
androidtextalarmlockscreen

how to change system alarm setting text dynamic


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

Solution

  • 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();
    }