0

I am making an alarm app using androids SDK and Java in eclipse.

I have a method that is called when the alarm goes off. This method is called even when the app is closed or the phone is locked. I want this method to unlock the phone even if its password protected(is this possible?). Then when the phone is unlocked (by the method if possible) (or the user if not) i want the app to be automatically started?

Is there any thing that would do this?

I do have experience in android but i am not an expert, so i would really appreciate everything explained to my beginner level. Some sample code would really help me, and would be totally appreciated.

Thanks, Jack

Jack Trowbridge
  • 763
  • 1
  • 8
  • 9

1 Answers1

1

The answer to this question of course depends on which version of android you wish to target, the following is an untested way that should work on API level 5 (android 2.0) and up if called from within an activity (or called on an activity):

getWindowManager().updateViewLayout(this.getCurrentFocus(), new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON));

This code causes the current view of the activity to be displayed over the lock screen by updating the view to use the SHOW_WHEN_LOCKED and KEEP_SCREEN_ON flags.

Euan Rochester
  • 183
  • 1
  • 8