Android Dialer Broadcast Receiver [duplicate] - android

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

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.

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.

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.

Related

How do I programmatically keep the device from turning off the display (Screen Timeout) when my App is closed?

I am using the following codes in my app to keep my device screen from timing out/shutting off. I have used right permissions in my Manifest.
Screen Keep On:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Screen Off:
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Those codes work if the app is running. However, when I close the app the flags seem to clear automatically leaving my device to timeout as normal. I want to keep screen on even if the app is closed. I've tried looking into Wakeful Receiver service but I can't seem to get it to work right. Also, I noticed Wakeful Receiver was depreciated in API 26. Any ideas? Thanks in advance!

Is there any possibilities to make an app that open even if the phone is lock?

I need to make an app that will open even if the screen is locked. Is there any possibilities to make this?
Use AlarmManager it runs of top of lock screen like a Default alarm application,we can have the access of GUI even if phone is locked.
see this tutorial for sample application which uses AlarmManager class
I don't think that you can launch your app when phone is lock.
Android only allow to run a Service in background and get Notification even your phone is locked.
That is my opinion might be some expert can know how to achieve this.
Open to update my answer.

how to detect shake event when my phone is in lock state

I read this unable to detect shake event when my phones screen is off in android article. But this question is differ from this.
I created an application which speak (using TextToSpeach API) time when I shake device. For that I have created a "Service" in which "ShakeListener" was registered. While I shake device, it will speak current time.
But this works fine while my device is "ON". When I lock my device, it stops working. Can any one elaborate what is the problem behind?
I think the problem here is that when you lock the device, it goes to sleep mode. And your ShakeListener doesn't receive shake events. The best way to implement what you want would be to register broadcast receiver to receive shake events. But as I know, android doesn't provide such broadcast. Another solution is to acuire a partial WakeLock. It'll prevent android from sleep. But of course it'll cause battery issues. Also take a look on this thread: Android accelerometer not working when screen is turned off
Probably you can not receive this notification until you patch some kernel implementation. Android doesn't broadcast such notification.

Android Service Listener for the wakelock screen

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 :)
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.
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.
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.

I want to the information about my screen (if it's locked or not), Android

i'm making a program that disables your wifi when you lock your screen
but i can't find an object the holds that kind of information (wether it's locked or not)
In most Android phones Wifi is turned off a few minutes after the screen is locked.
This setting can also be controlled by the user in Settings->Wireless Netowrks->WiFi->Advanced.
Anyway, if you want to tell when the screen is locked, register to receive the ACTION_SCREEN_OFF broadcast intent.

Categories

Resources