How to navigate back from programmatically opened overlay permissions screen in android? - android

How to navigate back from overlay permission screen?
I need to ask draw over other apps permission in order to show floating widget. I open overlay permission screen, but how to navigate back to app from there.

There is no API to navigate back programmatically. You can always try a "hacky" way like a background service that detects the permission every some time interval and, if granted, starts Activity again. But don't do that. The better way is to show a dialog with instructions on how to navigate back manually before asking for permission.

Related

AppState changes to background in android

I have integrated some code to handle a logic when the app is changing from foreground to background and vice versa. When the user navigates to the home screen we are requesting some permissions for location, camera and stuff from the user. The issue is in Android, in which when permission popups in the screen, app state changes to background, but I want the actual foreground -> background functionality to be triggered. I have used AppState in react native to achieve this functionality. It would be a great help if one can elaborate why the app is going to background when permission confirmation alerts popups? Thanks in advance.
Flag the permission like whenever you are gonna ask permission make isPermissionAsk to true. and in AppState Listener - for callback function where you are doing you stuff add a check on top
if(isPermissionAsk)
{ changePermissionAsk(false); return;}
In Android or iOS the permissions are OS managed features and the doesn't have any control other than requesting permission or getting state of permission. So when a permission is required you can think of permission app is in foreground which puts your app in background.

How to dismiss permissions dialog programmatically?

When the user pauses/closes the screen, while a permissions prompt dialog is active, the dialog persists over the locked screen when the user tries to use the phone again (and needs to make a choice for the dialog to go away).
Although a detail, it does not look very nice, and I would like to dismiss that prompt dialog in onPause(). How can I do that? Perhaps I should programmatically choose to deny permissions in onPause() instead?
From another point of view, it is also not very nice that user can't continue his task when returning to your app.
So, persistent dialog is a feature and the point is that user decides when to deny or accept permissions - it's the best to not do anything programmatically

Screen Overlay Detected PopUp Handle Programmatically?

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?

What is the difference between launch app from "recent apps" and tapping app icon

I'm working on large project, so there is some logic for saving application state, and then opening correct activity(fragment) when it comes from background.
But anyway, I've found that if user navigates through my app and then minimize it - android opens it from background in different ways in following cases:
User taps on app icon (behavior: user see home activity, doesn't matter where he was, when application was minimized)
User select app from android "recent apps" (behavior: user see exactly what he saw, when the application was minimized)
So, what is the difference between launching application from background by this two ways? I always thought, that it is the same mechanism, but, obviously, I was wrong.
Thanks for any answers
You should pay atention on the folowing docs Activity and Tasks. In short words: if user start app from recents you will receive onRestart before onStart (without onCreate it means that your app was just "suspended"). You able to save screen state using onSaveInstanceState(). But in general starting from icon and from recents - different application behaviors and you should provide proper code for this ways.
UPD
As described below root cause of unexpected behaviour was additional lunchmode attribute.
From what I experience as an Android user, both are same.
The difference we usually see is how we close the app
Press back button until app close / finish()
On this state no matter how we open the apps it will go to the main screen
Press Home button
On this state depend on the app. If the app does not handle any Activity the app will same with the first state. But if the app handle something like when onPause() the Activity then finish() the apps, then whatever you open with app icon or recent apps will provide the same result.
Correct me if I am wrong

Android: Create activity on home screen with user's permission

I have created a widget and it's working properly. If the user wants, he can add my application's widget on the home screen. However, what I want is, for my own code to "put the widget on the homescreen" with user's permission; because the widget is the most important part of the application, without which it'd be useless.
I'd like to implement something like the following:
a. For example, when an application tries to start bluetooth, the system tells the user "Ok dude, this application wants to turn on bluetooth, do you want to allow this?". Similarly, "Application X is trying to create a home screen widget, do you want to allow it?".
or
b. When you try to add a widget manually to homescreen, the system shows a list of available widgets that you can choose from, and then you select the one you want. Is there some way where I can call this "list of widgets activity" from my code, when my application starts up?
Thanks for the suggestions!

Categories

Resources