RequestPermission: Как дождаться получения разрешения?Android

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 RequestPermission: Как дождаться получения разрешения?

Сообщение Anonymous »


Android API 23 and above requires that "dangerous" permissions be confirmed at run-time. In accordance with other StackOverflow suggestions, I check for required permissions using checkSelfPermissions() and if required, call requestPermissions(). That works fine, but the request is handled asynchronously, i.e., requestPermissions() returns immediately. The problem is that my app goes on its merry way after requestPermissions(). Sometime later, the permission confirm dialog(s) appear but by that time, my app has tried API calls that fail.

I assume I need to wait until all permissions have been granted before proceeding in my app. I guess I could implement some polling kluge to do this but that's just too crude for me. What is the "Best Practice" to get around this? Various Best Practice descriptions in the documentation do not address this issue.


Источник: https://stackoverflow.com/questions/529 ... il-granted
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Android»