google maps - Client must have ACCESS_FINE_LOCATION permission to request PRIORITY_HIGH_ACCURACY locations in android 6 -


i have problem happen on devices android version 6.0

i getting following crash

java.lang.securityexception: client must have access_fine_location permission request priority_high_accuracy locations. @ android.os.parcel.readexception(parcel.java:1627) @ android.os.parcel.readexception(parcel.java:1579) @ ub.a(:com.google.android.gms.dynamitemodulesb:1191) @ to.a(:com.google.android.gms.dynamitemodulesb:2110) @ lw.b(:com.google.android.gms.dynamitemodulesb:148) @ ml.b(:com.google.android.gms.dynamitemodulesb:1164) @ nf.b(:com.google.android.gms.dynamitemodulesb:260) @ na.b(:com.google.android.gms.dynamitemodulesb:324) @ tn.a(:com.google.android.gms.dynamitemodulesb:78) @ maps.af.l.a(unknown source) @ na.a(:com.google.android.gms.dynamitemodulesb:13201) @ mo.g(:com.google.android.gms.dynamitemodulesb:499) @ mo.a(:com.google.android.gms.dynamitemodulesb:435) @ mh.a(:com.google.android.gms.dynamitemodulesb:1437) @ pj.a(:com.google.android.gms.dynamitemodulesb:227) @ oz.a(:com.google.android.gms.dynamitemodulesb:780) @ oq.a(:com.google.android.gms.dynamitemodulesb:1829) @ ot.handlemessage(:com.google.android.gms.dynamitemodulesb:5339) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:234) @ android.app.activitythread.main(activitythread.java:5526) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616)  

can please ?

here sample code can use request runtime permissions:

private static final int my_permissions_request_read_fine_location = 100; 

and

// here, thisactivity current activity if (contextcompat.checkselfpermission(thisactivity,             manifest.permission.access_fine_location)     != packagemanager.permission_granted &&                     contextcompat.checkselfpermission( getapplicationcontext(), android.manifest.permission.access_coarse_location) != packagemanager.permission_granted)) {     // should show explanation?     if (activitycompat.shouldshowrequestpermissionrationale(thisactivity,         manifest.permission.access_fine_location)) {        // show explanation user *asynchronously* -- don't block       // thread waiting user's response! after user       // sees explanation, try again request permission.      } else {        // no explanation needed, can request permission.        activitycompat.requestpermissions(thisactivity,             new string[]{manifest.permission.read_contacts},             my_permission_request_read_fine_location);        // my_permission_request_read_fine_location       // app-defined int constant. callback method gets       // result of request.    } } 

then can receive request here:

@override public void onrequestpermissionsresult(int requestcode,     string permissions[], int[] grantresults) {     switch (requestcode) {     case my_permission_request_read_fine_location: {         // if request cancelled, result arrays empty.         if (grantresults.length > 0             && grantresults[0] == packagemanager.permission_granted) {              // permission granted, yay! contacts-related task need do.          } else {              // permission denied, boo! disable             // functionality depends on permission.         }         return;     }      // other 'case' lines check other     // permissions app might request   }  } 

you can call in activity highly recommend read documentation here better idea.

i hope helps!


Comments