java - Android Studio: Variable 'requiredPermissions' is accessed from within inner class, needs to be declared final -
i'm working run time permissions , trying make method displaying permission rationale/s taken permission/s , rationale/s problem is: "variable 'requiredpermissions' accessed within inner class, needs declared final"
that's how call method:
showrationale(r.string.permission_access_fine_location_rationale, new string[]{manifest.permission.access_fine_location});
and that's method:
private void showrationale(int rationale, string[] requiredpermissions) { snackbar.make(findviewbyid(r.id.mycoordinatorlayout), rationale, snackbar.length_indefinite) .setaction(r.string.go_grant_permission, new view.onclicklistener() { @override public void onclick(view view) { // 'requiredpermissions' below causes problem activitycompat.requestpermissions(mapsactivity.this, requiredpermissions, my_permissions_request_access_fine_location); } }) .show(); }
you can realize onclick via interface, , not make variable final.
Comments
Post a Comment