android - Override lock screen with activity for alarm application -
i working on different type of alarm application , cannot seem figure out how have when alarm goes off , received, if screen off, turn on , open right applications activity turn off alarm.
basically same way regular google clock it.
i added these manifest file proper receiver , service tags.
<uses-permission android:name="android.permission.wake_lock"/> <uses-permission android:name="android.permission.system_alert_window"/>
i have alarm receiver class handles receive , calls wake lock class; here receiver below.
@override public void onreceive(context context, intent intent) { wakelocker.acquire(context); intent serviceintent = new intent(context, ringtoneplayingservice.class); context.startservice(serviceintent); }
and here beginning of ringtonplayingservice class called after received. handle playing of sound later in class didn't feel needed show.
notificationmanager notificationmanager = (notificationmanager)getsystemservice(notification_service); intent intentmain = new intent(this.getapplicationcontext(), mainactivity.class); pendingintent pendingintent = pendingintent.getactivity(this, 0, intentmain, 0);
and in mainactivity added these flags seem work lot of people.
getwindow().addflags( windowmanager.layoutparams.flag_fullscreen | windowmanager.layoutparams.flag_show_when_locked | windowmanager.layoutparams.flag_dismiss_keyguard | windowmanager.layoutparams.flag_keep_screen_on | windowmanager.layoutparams.flag_turn_screen_on);
i put them before setcontentview call.
i guess unsure of process , order needs in, in order work.
what thought pending intent created in mainactivity , once alarm fired, receiver picked , fired ringtoneplayingservice, handled playing of actual alarm sound. activity fired open activity flags on turn screen on , override lock screen.
Comments
Post a Comment