How to dismiss permissions dialog programmatically? - android

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

Related

How to navigate back from programmatically opened overlay permissions screen in 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.

Dismissing Android's system dialogue which was triggered by my app

The scenario is as follows:
First, my app executes the example code for requesting user's approval to make the device Bluetooth-discoverable. This request opens up some kind of a system dialog, which asks the user "An app wants to make your phone visible to other Bluetooth devices for X seconds" and the user has to either accept or reject the request.
While that dialog is still showing (meaning that the user didn't interact with it yet), and in the meantime something else has happened in my app, then I want to be able to dismiss the dialog or cancel that request, on behalf of the user. Like "forget it, that's not relevant any more".
Is that possible in any way?

Show dialog from service

I'm creating a voip app and when a call comes in I need to alert the user so they can accept or reject the call. I want a dialog like what hangouts uses:
I've tried using an alert dialog with type TYPE_SYSTEM_ALERT. However there are issues with this:
It requires ugly system permissions. (takes you to a full screen activity to accept overlay permissions)
It displays centered vertically not at the top over the top bar.
Any time anyone asks about this online everyone says your shouldn't be doing it this way, but doesn't tell you how to actually do it.
I didn't have to accept any overlay system permissions on my hangouts so how does google do it?
What is the correct way to display a dialog to the user from a service to accept a call?

Dismiss Permission Request Dialog on Marshmallow using back button

In my App, I am verifying required permissions for Marshmallow devices, in accordance to google guidelines.
When the permission is required, I am using the request permissions method for that:
mActivity.requestPermissions(permissionsList, MY_PERMISSIONS_REQUEST), which displays dialogs similar to the dialog below:
While this dialog is displayed, if the user presses the back button, I would like the dialog to be dismissed. Currently, pushing the back button has no effect.
Is there a way to dismiss those dialogs using the back button?
You know what, I believe it's a bug in AOSP. It should ignore Back button for no reason.
Reported an issue to bugtracker:
https://code.google.com/p/android/issues/detail?id=231017&thanks=231017&ts=1482770758

Bypassing dialog bug in Android

I have an application which in certain areas, a dialog pops up and restricts the user from proceeding. There are currently two types of dialogs. One restricts the user entirely from proceeding and the other allows the user to proceed if they click on "OK".
The problem:
When the dialog appears, if I close the application and relaunch it, the app bypasses the dialog and gains access to the next screen. On one of the cases, the app bypasses the screen and shows that screen which the user was previously on before the dialog appeared.
Does anyone have an idea what may be the problem?

Categories

Resources