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
Related
I have written an app that should be running continually event if device goes to sleep mode.I have tried many things like services (with startForground also) , alarm manager and persistant="true", but when device go to sleep (by user or by device) , my app is terminated.and even PowerManager does not work too.
There is an option in device setting that is 'Keep running after screen off' (in huawei device : setting > app > my app options > battery > Keep running after screen off). So when this option is active , the app is running for ever.I want implement something like this in my app programitically.
I saw some apps that implemented this , but I dont know how.
So how can I do that?
Use ForgroundService.
If you check your device applications with an app manager, you can see that some of them using a sevice that is always running. even if you stop them, some of them start working again.
see more about services behavior in android developer.
and search for "keeping a service alive".
On some devices (Huawei, Xiaomi, LG) there is a special setting that contains a list of apps that are allowed to run in the background. It sounds like you are talking about trying to accomplish the same thing. This cannot be done on those devices. On those devices, unless your app is added to the list of apps that are allowed to run in the background ("Protected Apps" on Huawei), the Android framework will not restart your app if it is shutdown. There is no way for you to programatically add your app to this list, and there is no way for you to work around this feature.
Certain apps need to keep the screen turned on, such as games or movie apps. The best way to do this is to use the FLAG_KEEP_SCREEN_ON in your activity (and only in an activity, never in a service or other app component).
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
I am developing one android application. In that i need to do below task. Can anyone suggest me how to do below task?
I want to force to user to stay on mine app, he/she can not open
another app. Only mine app is visible to top?
How can i achieve this?
Any help is appreciated .
I had a requirement where I need my App to run in foreground always, so that no other App should be running other than my App. Also, I had created a menu inside my App to Exit the Service that I created that keeps my App running always in foreground (not in this demo).
I had created a demo for the same in my github named as MyBackgroundServiceDemo.
Notes:
My requirement was for Tablet only.
I disabled back button of my App.
When user presses home button it will stay to home for 5 seconds (which is default by Android).
My Service keeps running constantly to keep track of Apps that are running.
I had modified the Service according to my requirement later on to keep track of my requirements. Same way you also modify the Service to meet your requirement.
Setting any application in Kiosk mode in run time and maintaining its state even after switching off the device in android.
We have created an application which display the list of all the installed application in the android. We select few of the application to run in kiosk mode. Now we want that even after restarting the device, application should be in kiosk mode.
But it is not happening in my case.
Kindly help us
I have Completed Kiosk mode in Android. I have two methods to handle this scenario
1.)Make your application as home launcher so it gets loaded whenever you restart the device.
2)If you dont want to make it as launcher, Then create a broadcast receiver with Boot_Completed receiver and start your application from it.
On the Android Market there is an app called Sleep Timer, and it is a type of alarm clock that brings runs the alarm even though you locked your phone while on facebook. I made a type of app that detects movement however it only works if the phone is left on that app... How can I make it work when the app wasn't left upfront, but is still running in the background?
You should take a look at Android Services, which provide the functionality you seek. Basically they enable you to create components that run in the background even when the user switch away from your application.
You can find a very good introduction to them here: http://developer.android.com/guide/components/services.html
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.