How to Capture Image When Device is Locked [closed

2019-05-19 02:40发布

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.

2条回答
在下西门庆
2楼-- · 2019-05-19 03:22

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:

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.

查看更多
祖国的老花朵
3楼-- · 2019-05-19 03:34

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

查看更多
登录 后发表回答