I am trying to ask runtime permission for location [android.permission.ACCESS_COARSE_LOCATION ,android.permission.ACCESS_FINE_LOCATION ,android.permission.ACCESS_BACKGROUND_LOCATION]
from Android-OS 6 to OS-10. the System permission popup working fine for me.
But when I am trying my code on OS 11[API level 30] I am not able to see the popup.
I am so confused why it is not showing on UI.
I have tried asking permission individually. It works fine on OS 11.
But when I am trying to get all the above three permission together. I am not able to get the system permission popup.
Manifest-file
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
MainActivity
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION}, 101);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (grantResults != null && grantResults.length > 0)
switch (requestCode) {
case 101:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED || grantResults[1] == PackageManager.PERMISSION_GRANTED || grantResults[2] == PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "onRequestPermissionsResult: ");
}
break;
}
}
}
question from:
https://stackoverflow.com/questions/65847184/android-operating-system-11-not-showing-permission-popup 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…