I am adding android auto support in my app. My app requires location permission so trying to request location permission from android auto screen.
according to this guideline grant-permissions-on-phone
User can grant permission from phone screen.
I added following code for that
`List permissions = new ArrayList<>();
permissions.add(ACCESS_FINE_LOCATION);
permissions.add(ACCESS_COARSE_LOCATION);
getCarContext().requestPermissions(
permissions,
(approved, rejected) -> {
LogUtil.d(“LOCATION REQUEST”, approved + ” ” + rejected + ” “);
if (!approved.isEmpty()) {
mLocationPermissionCheckCallback.onPermissionGranted();
MapScreen.apiCallManagement = 3;
MapScreen.canCallAPIForFuelStations = true;
finish();
} else if (!rejected.isEmpty()) {
intentForPermission();
}
});
private void intentForPermission() {
Intent intent = new Intent(carContext, ForAndroidAutoRequestPermissionActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.putExtra(“RequestPermission”, true);
getCarContext().startActivity(intent);
}`
ForAndroidAutoRequestPermissionActivity
activity I am showing popup which redirects user to setting screen to allow location permission if user denied to allow location permission.
but for some devices like Xiaomi this logic is not working because it’s not opening app in phone or not showing location request pop up in phone.
also so I thought to add notification for that but still new android versions requires notification permission. It became infinite loop for me.
Please help to resolve this issue.