iam developing screenlock app for android using a React Native and a little annoyed with the screen pinned dialog that always appears, is there a way to just get rid of it? so what I really want is no dialogue interaction at all with the user
enter image description here
If you're calling startLockTask() and your device isn't set up as a dedicated device with your app whitelisted, then no you can't prevent it:
Otherwise, the current task will be launched into screen pinning mode. In this case, the system will prompt the user with a dialog requesting permission to use this mode. The user can exit at any time through instructions shown on the request dialog.
The dialog is there to help users understand what's happening, give permission for the app to take over their screen, and know how to get out of it later. It's baked into Android by design, so malicious apps can't cause problems - it's just a limitation you have to deal with, unless you're working with a dedicated device (which can be set up to give apps more control and users less)
Have you thought about immersive mode instead, where you hide the nav bar? The user can get out of that too by swiping to reveal the controls, but it's less intrusive. There's no way to automatically lock the user's screen with no interaction though
Related
I am working on an android app that should be used by students in some kind of practical test.
I am using the screen pinning that was introduced in Lollipop (startLockTask()), so when my app is launched the user needs to allow the locking.
I couldn't find a way to know when the user click ok for the locking and when he unlock the pinning? (The user can cancel the lock by holding both the Back and Recent buttons).
I am not looking for a way to know if the user currently in lock screen (getLockTaskModeState ()), i want to know if i have a way to handle the events of locking or unlocking.
I want that in the begining of the test i will be able to send information to my server if the users 'logged in' properly (by allowing the lock), and as well if the user unlock the device before the end of the test.
EDIT
Hey, people!
Please explain yourselves after downvoting!
If I wasn't exaplaining myself - i will try again if you will let me know.
I read a lot of questions and answers about general lock screen, but not the one of app pinning, I also read about check the status of the current task- if it is locked or not, but i didn't find answer to what i am asking - is there a way to handle the event of unlocking the 'screen pinning' of a specific app.
So please, explain your downvotes!
Device Admin Recevier class give you the event of pinning and unpinning... However the example use the class when the installed app is provisioned for device owner.. Not sure if you could use it. You may refer to this too : How to be notified when screen pinning is turned off in Android 5.0 Lollipop?
https://developer.android.com/reference/android/app/ActivityManager.html#getLockTaskModeState()
Just use the function as stated in the link.
I'm facing a issue on the devices with Marshmallow + and i'm trying to find out a solution programmatically. When ever the code executes for asking user a dangerous permission a "screen overlay detected" popUp appears and takes the user to "Draw Over apps" Settings. It's hard for a user to determine which app to select to turn off the overlay feature. A very ordinary user might get confused what to do and could see it as a gimmick, would simply press back button and kill the app. Turn out to be a bad user experience.
It may be not rally necessary to turn off this feature. Is there a way to handle this programmatically. By pass this Popup and stay on the main track?
I installed an app on my android phone to safe lock certain apps with a password. Since I installed it, sometimes, regardless what i'm doing on the phone/which app i'm using, a full size screen with advertising appears and I have to click an "X" to close it or press back/home button.
(Can be that this screen appears randomly only when I digited a password to unlock an app therefore the safe lock app was active let's say, not sure.)
I was anyway wondering what sort of code is used for this? Anyone?
I'd need it for a less despicable cause: in order to show a transparent view with alertdialog when my timer is up and the app is closed, to imitate the original builtin countdown timer.
Is there any programming tricks that makes your application unclosable?
For example: You touch the back or the home button, but they don't do anything.
Or at least is there a way that your application blocks some applications to open?
I don't think you can stop user from moving your application to background unless it's some kiosk mode app. And the method to do that is to become device administrator and override all possible callback methods - home, back, settings, notification area etc.
If you just want to prevent your app from getting closed due to user activity you can show a persistent notification. This will allow you app to run in background even if user presses home button.
Make a launcher/Home screen app:
When users click the home button, your app will show.
You control ALL apps that can be started
On devices running android lolipop, you can use the screen pinning option available in your ROM.
NOTE: This is ROM feature, you don't have to do anything in your app.
See this great article about it.
yes its to get set the on backpressed method to.
moveTaskToBack(true);
finish();
Are you trying to hack in android OS ? Let me tell you that android apps are sandboxed, which isolates your app data and code execution from other apps.
I'm writing an anti theft app, and I want when sim card is changed a dialog opens on boot and tell the finder to bring back the phone. This activity must be unleavable, so he can't leave it unless the correct code is entered.
Other situation is when user send a lock SMS to the phone.
I know how a device admin can lock the phone, but lock don't tell the message and the password can't be entered. And lock may not have a password or pattern so the finder can pass it easily.
Maybe a combination of device lock and a full screen activity which disable the keyguard do the job?
In my research, without being installed at the OEM level, you can't make it 100% un-leavable, just really annoying.
In an app I wrote for businesses which use a kiosk, since we weren't at the OEM level, we just kept the menu bar hidden and set the app to be loaded whenever Home was hit. Keeping the menu bar hidden was a pain, but was achieved by making it invisible and then when re-triggered, making it go away after 1 second. It's still able to be exited by hitting the clock in that 1 second, though. :(