I am currently looking into creating a location aware security app whereby the camera is disabled if the phone moves into a designated location. I am now able to disable and enable the camera using the Device Administrator class and calling setCameraDisabled to disable the camera. However, the problem I am encountering now is that if the setCameraDisable method is called when the camera is running, the camera app doesn't close. The camera app would only be disabled on the next launch. As such I am wondering is there is a way for me to kill the camera process before calling the setCameraDisabled method. Thanks in advance.
Try this
android.os.Process.killProcess(android.os.Process.myPid());
Related
I am using the code below to start an installed camera app (not developed by me) from a background service in an app I'm working on.
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.sec.android.app.camera");
startActivity( launchIntent );
I need to determine if the camera app is done loading and ready to use so I can prompt the camera to take a picture. After the picture is taken, my app will be brought back to the foreground and show a screensaver until the camera is started again or brought back to the foreground to take another picture. Is there a way to verify that the camera app is loaded and ready each time before attempting to send it commands?
For clarity, I'm not asking about how to check this on a camera app specifically. I'm trying to learn how I can start just about any app (not developed by me) and listen for it to be completely loaded and ready.
I am using the code below to start an installed camera app (not developed by me) from a background service
Launching activities from the background is not supported on modern versions of Android.
Also note that many devices will not have that particular package.
I need to determine if the camera app is done loading and ready to use so I can prompt the camera to take a picture
There is no canonical definition of "done loading and ready to use". And, in general, there is no means for you to monitor the operations of another app, for privacy and security reasons.
Also, outside of accessibility services, in general, you have no means of telling a running app to do anything unless it has a specific API for that purpose. Even with accessibility services, I suspect that it will be difficult to come up with an approach that works no matter what the camera app is.
If, from the foreground, you want a camera app to take a picture, use ACTION_IMAGE_CAPTURE. Or, integrate camera functionality directly in your own app, such as via CameraX or other libraries.
I would like to learn more about how the camera can launch over the secure lock-screen (PIN).
My goal is to have a user select either their default camera app or another camera app (like Google Camera). I would then like to invoke or launch the camera without the user being required to enter their pin code, etc.
I have read that this is possible starting with Android 4.2.
Here is the post:
Launch camera activity over lock screen
Currently in my test build the camera app launches, but the user my first unlock the device.
Any help is appreciated.
Thank you.
I want to write application on Android that starts in background when user launches a built-in camera (it is important: build-in camera, not an application) and do some actions after user makes a photo.
Is it real? If yes, how to implement this?
I doubt if this is possible. There is no mechanism which android provides that causes a broadcast to the system that Camera has been launched. Plus, you cannot modify the contents shown on the screen as the Camera application is in command. The only way out is to have a MediaScanner and FileObserver to check when a new picture is created in DCIM/Camera/ folder and make your app act accordingly
I want to enable/disable camera programmatically in my application.
You cannot do this from a regular app. You can do it from a device administrator, but the user has to explicitly enable it and it is only available on ICS. Here's the reference: http://developer.android.com/guide/topics/admin/device-admin.html
The OP is asking for any ideas, I got one idea and it could possibly work even without using the API provided by ICS.
for lower API version than ICS, you can Start a service that will lock the Camera when the screen is On and Release it when the Screen is Off. This is to minimize the usage of battery.
Since, only one process can use the Camera at a time, other applications like the Camera App will not be able to use the Camera.
The challenge now is how to ensure that the Service Hogging the Camera is always Running and prevent it from being uninstalled by the user.
Well, just a thought ;)
Yes, you can use DeviceAdministration class and control the camera source(block and unblock). This is a repo with an example.
Yes you can disable or enable camera but your app must device admin enabled.Following enables or disable camera:-
devicePolicyManager.setCameraDisabled(compName, isCameraOn);
**isCameraOn** is boolean true or false
I am working on an app, in which i need to stop some functionality of phone,
which include :
1) making or receiving phone calls,
2) use of Bluetooth or wifi,
3) Use of camera,
these feature will lock as soon as this app get installed, and will be locked until the get uninstalled, first two i have done, but i dont know how to achieve 3rd task, as i have tried locking the camera with my app, but after some time it automatically unlocked.
any clue/pointer/help will be appreaciated. Thanks
To stop camera usage I would suggest to intercept Intent.ACTION_CAMERA_BUTTON broadcast and just abortBroadcast() - in this case camera usage will be blocked.
The same approach I believe can be used for wifi and bluetooth, though I didn't check it.
Update for sure phone usage can be handled in the same manner.
Try to register broadcast receiver for BOOT_COMPLETE event, and open camera device[s] and lock() it - nobody will be able to use it until lock is given up. And I think it will stay even after your process is killed ( not sure though)
You may also try to FUBAR camera with some weird settings (I managed this sometimes, though can not explain how. - camera was unusable until reboot)