Unsolved How to catch onRequestPermissionsResult for QtActivity in Android 6?
-
To properly process permissions for Android M I call requestPermissions(...) Android method. It works in my app and shows dialogs with requests. But I cannot catch user's response cause my onRequestPermissionsResult() method is newer called. Here is my simplified code:
public class PlayControl extends QtActivity { ..... public static boolean requestPermission() { boolean p = true; if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) { Activity a = QtNative.activity(); Context c = a.getApplicationContext(); if( c.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED ) { ActivityCompat.requestPermissions(a, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO }, 1); p = false; } } return p; } public void onRequestPermissionsResult(int requestCode, String permissions[], int grantResults[]) { NativeCall.permissionsGranted(); } }
The NativeCall itself works properly - it is used in other parts of code. But NativeCall.permissionsGranted(); is newer called. I checked this with some other code and found that onRequestPermissionsResult() is newer called.
How to workaround this? Is there a way for Qt application get user's response to permissions requests?
-
have you tried the workarounds here ?
https://bugreports.qt.io/browse/QTBUG-50759?focusedCommentId=366042&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-366042 -
No, I cannot use this. I build app with Qt 5.6 historically and cannot quickly change version.
-
It work after import androidx.appcompat.app.AppCompatActivity;