React native – Unable to use Permissionsandroid request location permissions

I tried to request runtime location permissions, but my promise kept throwing this exception:

“Trying to use the permissions API, but the host Activity is not implemented PermissionAwareActivity”

My code looks like this:

PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION)
.then((preGranted ) => {
console.log('pre-granted', preGranted)
if (!preGranted) {
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{'title':'Enable location','message':'Boss said so..' }
)
.then((granted) => {
if (granted) {
console.log('GRANTED AFTER ASKING:', granted)
debugger
}
})
}
})

< p>In my list I have:

Someone met Have you been to the news? What is PermissionAwareActivity? I cannot find anything about it on the Internet.

What is PermissionAwareActivity

PermissionAwareActivity is an interface that helps you obtain runtime permissions. You must implement these methods in your own activities.

public interface PermissionAwareActivity {

int checkPermission(String permission, int pid, int uid);


int checkSelfPermission(String permission);
< br /> boolean shouldShowRequestPermissionRationale(String permission);

void requestPermissions(String[] permissions, int requestCode, PermissionListener listener);
}

I tried to request runtime location permissions, but my promise kept throwing this exception:

“Trying to use the permission API, but the host Activity does not implement PermissionAwareActivity”

My code looks like this:

PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION)
.then((preGranted) => {
console.log('pre-granted', preGranted)
if (!preGranted) {
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{'title':'Enable location','message':'Boss said so..' }
)
.then((granted) => {
if (granted) {
console.log('GRANTED AFTER ASKING:', granted)
debugger
}
})
}
})

In my list I have:

 

Has anyone encountered that message? What is PermissionAwareActivity I cannot find anything about it on the Internet.

What is PermissionAwareActivity

< p>PermissionAwareActivity is an interface that helps you obtain runtime permissions. You must implement these methods in your own activities.

public interface PermissionAwareActivity {

int checkPermission(String permission, int pid, int uid);


int checkSelfPermission(String permission);

boolean shouldShowRequestPermissionRationale(String permission);

void requestPermissions(String[] permissions, int requestCode, PermissionListener listener);
}

Leave a Comment

Your email address will not be published.