I want to capture image automatically by using either front or rear camera from an android device when screen is locked and someone try to unlock it. I checked it is possible in Android and some application is available in Market. Please help.

- 3,201
- 37
- 66

- 3,568
- 7
- 34
- 62
-
Register for the screen on event via BroadcastReceiver and launch an activity that uses the Camera API to take a picture. – Gabe Sechan Apr 17 '13 at 07:18
-
will you please elaborate this.. – Krishnakant Dalal Apr 17 '13 at 07:20
-
Hi, I managed to find the following application on Google Play: https://play.google.com/store/apps/details?id=com.midasensemble.hiddeneye see if it suits your needs. – g00dy Apr 17 '13 at 07:22
-
Yes there are number of application for this but How it is working. how can i do that. – Krishnakant Dalal Apr 17 '13 at 07:23
2 Answers
Generally speaking, you have two subproblems:
1) Detect when device is unlocked
As I understand it's reasonably straight forward.
All you need is to have BroadcaseReceiver subscribed to this action (http://developer.android.com/reference/android/content/Intent.html#ACTION_USER_PRESENT).
You read more about this here:
http://funwithdc.wordpress.com/2012/02/12/the-problem-with-androids-action_user_present-intent/
Why is my BroadcastReceiver receiving ACTION_USER_PRESENT twice?
2) Take a picture from bakground
I am not 100% sure whether it's possible or whether it works on all devices. As I know Camera requires to have some preview. However, as I understand it could be invisible preview.
Generally speaking, you want to take a picture either from broadcastreceiver or if you will have problem with that, just create additional service, trigger it from broadcast receiver and take a pictures from there.
Take a look at these questions (they show samples how to do invisible preview):
Combining these two things should give you what you want.

- 1
- 1

- 22,758
- 18
- 92
- 184
-
Thanks Victor for your reply I am able to get the broadcast for user wrong input. also I am able to take the image from background but Image is black... I need to resolve this only Here is the more detail on this : http://stackoverflow.com/questions/16075726/capture-image-while-device-is-locked-with-password – Krishnakant Dalal Apr 22 '13 at 05:42
You can override the lockscreen to be your app, and then you can capture images like the rest of the app (google can help you with that).

- 745
- 8
- 22
-
Yes that was a solution but i Don't want to override the native lock screen. And it is possible to do that too. – Krishnakant Dalal Apr 17 '13 at 07:22