My question specifically concerns the Samsung Galaxy Camera devices. It ships with a customized camera application. I guess Samsung developed their own. Since this device can be seen as a camera instead of a phone with a camera they seem to decided that their camera app should start on boot, in contrast to other devices which take the user to the home screen after boot completes.
Now, in our szenario we ship the device with our own application that has its own camera interface. We could run our application in kiosk mode but we want to allow the user to use other apps that might be helpful for his daily work as well.
So ideally, the device should start the home screen after boot completes. The user could then decide to start our app or another app. But if this isn’t possible it would also be ok if our app would start on boot instead of the home screen (since the user would reach the home screen with the home button)
Since I don’t see any chance to force the home screen to appear after boot completes, I tried to start our own application by default. To implement that I created a receiver with the following filter:
<intent-filter android:priority="1000">
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
When the intent is received, I start the main Activity of our application.
In the result, after booting the device, Samsungs default camera app will start first. You’ll see their main Activity and the most annoying part: the camera lens will be fully extended. A split second after this our app starts automatically.
My guess is, that Samsungs camera app also reacts to the boot-completed-event. Is there any chance that we could prevent their app from being started?
I believe this can be achieved - albeit in a convoluted manor - without rooting using DevicePolicyManager. By making your app a device administrator and disabling the camera the built in camera app won't launch on power up (nor camera button press). Once your app has launched re-enable the camera and have fun.
I haven't had a chance to create the code (and will update this answer when I have), but I have tested to an extent using the DisableCameraDevice app from the play store. With this app setup the camera app doesn't launch at startup and my app which receives BOOT_COMPLETE launches after a few seconds of homescreen time.
It also doesn't stop the camera button events (but does stop the camera app) so you can do the same for this (which also seems to ignore android:priority values).
If you wanted to go further you could even make you're camera app respond to the ACTION_MAIN, CATEGORY_HOME intents mentioned by CommonsWare and persistently select it as the homescreen app.
Combined with a full screen app which doesn't display the home/back buttons you're locked down pretty well for a fool proof camera to give customers.
The camera app uses the BOOT_COMPLETED permission attached to a receiver. It is a system application, so you would need root to modify it on the system level. If you are packing your own firmware, this would not be an issue. The standard launcher does not have the standard boot permissions, but your app would. This would avoid the issue of not booting to anything by simply removing the permission. Also, a priority of 499 is better to fall within the limit of 500.
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 am using kiosk mode in my android app. Here kiosk service should be called every two second and the app open for every two seconds. My app needs to access gallery or camera app. But my app does not let me access these things because every two seconds it comes to foreground if we try to go to other applications. Now my problem is i need to access camera and gallery in kiosk service which should be called for every two seconds.
Afaiu you are using background service which runs continuously in gap of 2 second.
Instead of using background service i would suggest you should use screen pinning option for android lollipop or more devices. To get more information regarding this you can read http://www.sureshjoshi.com/mobile/android-kiosk-mode-without-root/ .
Also ,you have to make your application a launcher application,so that everytime user presses the launcher icon your application starts.
To disable power on/off button you can use System Dialog Disable feature.
By using this you can get following benefits :-
1) Power consumptions/Memory usage is minimized.
2) According to your usage you can disable/enable the kiosk mode.
3) You can start the other application from your application by disabling the kiosk mode application.
Regards
Ajay
I'm trying to start an app upon the first boot of the device before the keyguard appears. I need to ensure the first thing the user sees after the boot animation (which I've also changed) is this app. My app is just three screens of text in fullscreen mode with a next button in between them.
I realize that for most cases, this would be a terrible user experience. However, the phones we're shipping have a very specific purpose and because of this I need to meet the following criteria:
my app needs to be the first thing the user sees (after the boot animation of course) when they take the phone out of the box and power it on for the first time.
after the first boot, the phone should function as normal (i.e the keyguard should appear upon bootup instead of my app).
this only needs to work for lollipop since that's the android version we're shipping.
I can modify the Android framework if needed, but a solution where I don't have to is preferred.
My (Failed) Approach
Create an app that starts upon boot. Have the app dismiss the keyguard as the first thing it does.
The problem I found with this approach is the keyguard code is called before the app initialization code so the user sees the keyguard briefly and then sees my app.
A Possible Solution
I think the best way to do this is to add code in the framework to call my app before calling the keyguard. I'm imagining having a boolean that's used to keep track of whether it's the first time the device is powered on. If that boolean is true, open the app. If not, open the keyguard.
The problem is there's a lot of code in the android userspace boot process and I have a quickly-approaching deadline (don't we all?). How can I modify the framework code to show my app before the keyguard?
If there's a better way, please let me know that too!
I want to write an application that can prevent some application from launching. My requirement is to block some application for some period. So what is the way to block or prevent others application from starting or launching through my application.
My question is -- Is it possible to prevent launching other application from my application? If yes then what is the way.
I tried killing the running application. But it only kills when the application is in the background. When the application is in opened state(displayed on the screen) the killing of the application is not working.
So what is the way to block or prevent others application from starting or launching through my application.
Write your own home screen, so you are the one doing the launching, and implement your launching rules there.
This will cover basic scenarios. It will not help with:
Stopping apps that are launched via notifications (e.g., in response to an incoming SMS)
Stopping apps that are launched via other things in the system bar on tablets (e.g., some tablets let you get to the Settings app from there)
Stopping the user from rebooting their device in safe mode and getting rid of your home screen
The only way to handle those scenarios is to create your own ROM mod with adjustments to the operating system, then distribute that ROM mod (e.g., on your own devices).
So I'm trying to do what many people have tried before: create an app that does not respond to the Home button. I've looked at many of the similar questions posted here on SO, but none of worked the way I wanted them to.
One thing I tried was making my app essentially another launcher. (Note: a little amount of user input is required to make it work.)
From my application's Manifest:
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
I also disabled the back button and made the launch mode "singleInstance."
I think Toddler Lock did something similar, but my implementation does not behave exactly the same way. Using my implementation, my app exists as the default home launcher indefinitely including after the application has been exited. Is there any way to declare the same behavior in a place other than the Application Manifest where it can be turned on temporarily or and turned off when the app is exited?
Car Home also does a similar thing and actually does it better than Toddler Lock. I'm not sure how it does it (maybe it has more permissions since it is a native app), but it manages to do the same thing without requiring the user to accept the alternate Launcher or choose the app as the default Launcher. Anyone have any idea on how it does it?
hackbod is essentially correct. I have gotten much of the desired behavior by
Make a "capture home key" activity
as described in the question. This
is not the main activity of the
program.
In the manifest, disable it.
In the app, enable the "capture home
key" activity when you want the home
capture to happen, and disable it
when you want to exit.
The only question is what the capture home key activity should actually do. In my case, I needed it to just go to the start of the app... so it manufactures a CATEGORY_HOME intent, tests that it resolves correctly, and if so forwards on to the app. If it doesn't resolve correctly, it notifies the user, waits for the user to be ready, and then uses that intent. This way if the user chooses your app but doesn't make it default, he'll get prompted again.
To disable this after the user has enabled your app as the home app, disable that activity with PackageManager.setComponentEnabledSetting(). Note this implies that the activity that is overriding home should not be the main activity of your app, or else upon disabling it the user won't be able to return to your app.
CarHome is very different -- when Android is in a different UI mode (in a car for car mode or on a desk dock for desk mode), then a different Intent will be launched when the user presses home so that they can have a different "home" in that environment. If you are not writing a car mode home screen, you should not be using this.