I am developing such application, that
is running in full screen KIOSK mode and it is advertising until a user touches the screen
when somebody touches the screen the application finishes the advertising activity and start a service
when the activity is in the background, user can try the device (e.g. open Camera, check Android About page in Settings)
to prevent user to do some harm (e.g. factory reset device) I set the application as a device owner and set some user restrictions
the service watches the touches on the screen and after 30 seconds it restarts the advertising
to capture screen touches in a service I add a 1x1dp transparent view to the WM as an overlay and watch the outside touch of the view
My problem is, that
I can't disable user to turn off Manage Overlay permission in the Android Settings, if the permission is turned off it halts the advertising process
My second approach is that I write an Accessibility Service and handle the TOUCH_INTERACTION_START and TOUCH_INTERACTION_END event types, but in this case user can disable the Accessibility Service so the problem is the same
I would be very grateful if somebody can help me how to pass this problem or could suggest a third kind approach
Thanks,
Related
According to the fact that (of course) an app can run on different devices, I'm searching a way to list the hardware buttons available on the smartphone.
Usually Volume, Power are always there. Sometimes a button that launch camera is present, sometimes a button that launch "Google Now" is present, etc...
How can my app knows which are available?
Final target for me is to use an hardware button to perform a precise action of my app.
I implemented it with volume button, but it works only if screen is on and my app is in foreground, while I need to do that also when screen is off and my app is in background.
I've a problem with my app, when I press side standby(screen disable) button when app is opened and turn on screen again and unlock my app is now in background, also, when I reopen it from background it restarts with loading screen(so it loose my previous app state and reset it). But when I place my app in background going to home and reopen it, it start from where it was when it goes in background. Same if I close screen when app is already in background.
How can I solve this problem?
Android usually keeps your app on the foreground even if you press on the power button (side standby).
Try using the SavedInstance as mentioned by Abo Hani.
Otherwise,
Try testing the app on other devices with different android versions.
Android only sends apps to the background if it needs more resources(memory,network,etc) to process other apps. Sometimes it might also kill the app.
I want my app automatically open when user click (for example) chrome or any other apps.
How to do this?
My app is for preventing people use cell phone all the time.
Explicitly, there is a mission in my app. when user starts this mission, user cannot use other app until they give up the mission.
User can minimize my app, but when user click another app, my app will prompt programmatically to tell user not to use the cell phone.
Instead of preventing user to launch other apps, I think you should use activities' life cycle. You can add code in onPause() and detect user press home button or back button. And when your activity is not on foreground, you can pop a dialog or something to remind your user focus on his work not his phone. BTW I do see the positive side of your app.
I am writing an Android application that should display the specific image (Bitmap) while the user is charging his phone.
The life-cycle:
User installs my application.
User does not have to run my application.
When user connects the charger (usb to PC or just an charger), my application automatically starts and show the image on the screen (during charging).
User stops charging the phone, my application hides the image.
How could I achieve it?
If i remember correctly you can get the "ACTION_POWER_CONNECTED" event with a BroadcastReceiver to do whatever you want. Just Google, there are pretty good tutorials ;)
I have a flashlight app, and if the app is paused, the camera is released. Be it the home button or power button. I want the camera to stay alive when either of these are pressed and released when I close the app completely. How do I go about doing this?
This is intended functionality to ensure you do not consume more power than necessary, and that other software on the device can obtain access to the camera on demand. Some useful information on the Activity lifecycle can be found here.
Generally, an Android developer's options are:
Build a custom Android firmware that gives your app privileged
access to the camera. This option is usually only really feasible if
you are providing dedicated hardware, with this firmware and your app
pre-installed.
Approach your app design in a different way, that does
not require the use of the camera when it is not in the foreground.
Stick with the existing behaviour, and detail the caveats to the user on the market (and possibly as a first-time pop-up dialog to grab their attention) to reduce the number of complaints.