0

Hii all,

Im developing an emergency calling application. What i want is when some person uses this specific code the phone will unlock and then only my application would be running. Im juz thinking i need a reciever for it and just wondering wether i will have to create my own Home screen and a lock screen for my application. any ideas on this please???

many thanks in advance :)

Roses
  • 59
  • 2
  • 8

3 Answers3

2

You can create a BroadcastReceiver and register it with your application to listen for Intent.ACTION_SCREEN_OFF, Intent.ACTION_SCREEN_ON, and Intent.ACTION_USER_PRESENT. Between SCREEN_OFF and USER_PRESENT, the phone is locked.

LeffelMania
  • 12,765
  • 4
  • 32
  • 34
2

There's some caveats in just doing SCREEN_OFF and USER_PRESENT 1) Phone isn't locked right after screen off if the screen timed out by itself, there's a few second delay 2) If screen goes off for other reasons (phone call) it might not be locked at all. 3) You'd have to be monitoring them the whole time, if you're started when the phone is locked you wouldn't know

You can use the KeyguardManager http://developer.android.com/reference/android/app/KeyguardManager.html and check inKeyguardRestrictedInputMode()

Another option would be to use the PowerManager http://developer.android.com/reference/android/os/PowerManager.html and check isScreenOn() if you actually just care about screen state and not keyguard state.

Kevin TeslaCoil
  • 10,037
  • 1
  • 39
  • 33
0

There is no sanctioned way to replace the lock screen. See Is there a way to override the lock pattern screen?

The previous answer was to another question that got merged with this one:

I would look into ACTION_NEW_OUTGOING_CALL, and also at this Android Developers blog post about receiver priority.

Community
  • 1
  • 1
jakebasile
  • 8,084
  • 3
  • 28
  • 34
  • Can some one suggest me how to implement it please? – Roses May 02 '11 at 08:13
  • actually what i want is to recieve the keypress events of the android dialler – Roses May 02 '11 at 08:14
  • Hey awesome it worked for me Jake I used the action new outgoing call and it was really simple. but the problem i have is my app doesn't receive intents from the emergency dialer. I was wondering whether there are specific permissions or actions related to the manifest file seems like there is nothing...Any tips on it??? – Roses May 02 '11 at 08:54
  • I'd bet you can't intercept emergency dialer calls, to prevent a malicious app from stopping a person dialing 911 or equivalent. – jakebasile May 02 '11 at 13:07
  • My point is that i need to fire an intent while the phone is locked. is there any suggestion how i could do it? – Roses May 03 '11 at 19:03
  • I'd need more information, but you might want to look into a wakelock. Feel free to ask a new question and I'll look into it. If this answer helped you, please mark it as the answer as well so other people can find it! – jakebasile May 04 '11 at 00:01
  • Hey jake thanx for ya help. What I want to do right now is to fire a service from the emergency dialler or if the phone is locked. What i did was press this press 123 and press the call button then the service can be created. but i dont think its a good mechanism for it because it is like dialling a call. if im to do the same while the phone is locked I dont think i can do because calls are restricted. – Roses May 05 '11 at 09:27