Comments (7)
@seang96 are you calling EasyPermissions.onRequestPermissionsResult
in your Fragment?
from easypermissions.
Also make sure you always call super.onRequestPermissionsResult(requestCode, permissions, grantResults);
whenever you Override it
from easypermissions.
Yeah, the method has both of those in there. I Implemented the class, I also tried @AfterPermissionGranted in the method that checks/requests/and handles what to do if the check succeeds, which only calls when I first check it.
@AfterPermissionGranted(RC_FINE_LOCATION)
public void locationPermissions() {
String perm = Manifest.permission.ACCESS_FINE_LOCATION;
if (EasyPermissions.hasPermissions(getContext(), perm)) {
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.setMyLocationEnabled(true);
} else {
EasyPermissions.requestPermissions(getContext(), "Would you like your location displayed with the bus route?", RC_FINE_LOCATION, perm);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
// Forward results to EasyPermissions
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}
@Override
public void onPermissionsGranted(int requestCode, List<String> perms) {
Log.i("mapFragment", "onPermissionsGranted:" + requestCode + ":" + perms.size());
}
@Override
public void onPermissionsDenied(int requestCode, List<String> perms) {
Log.i("mapFragment", "onPermissionsDenied:" + requestCode + ":" + perms.size());
}
from easypermissions.
Where you have requestPermissions(getContext(), ...
) can you try replacing it with requestPermissions(this, ...)
so that the object requesting the permissions is the Fragment
?
from easypermissions.
Oh well, that worked. Was getContext() causing the method to be sent to the activity that the fragment is running in instead of the method inside of the fragment itself? Thanks for the fix.
from easypermissions.
Yeah returning results of permissions or startActivity calls to Fragments
relies on some interesting hacks that put the Fragment ID in the request
code. But if the calling context is not a Fragment the system doesn't know
to do that.
On Mon, May 23, 2016, 6:24 PM seang96 [email protected] wrote:
Oh well, that worked. Was getContext() causing the method to be sent to
the activity that the fragment is running in instead of the method inside
of the fragment itself? Thanks for the fix.—
You are receiving this because you commented.Reply to this email directly or view it on GitHub
#20 (comment)
from easypermissions.
I missed the last param so that i didn't receive @AfterPermissionGranted method calling.
Replace your code from
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults);
to
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
from easypermissions.
Related Issues (20)
- Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller (has extras) }
- onRequestPermissionsResult not called in non-activity class HOT 1
- onRequestPermissionsResult not called if user presses HOME button
- Vtf HOT 1
- onRequestPermissionsResult() deprecated
- @samtstern This may be the same crash, without obfuscation. I got it during a stress test.
- Request: Make easypermissions library target to android api 33 HOT 4
- doc: inconsistent sample code for AfterPermissionGranted annotation
- h
- b
- the t
- java.lang.NullPointerException
- M HOT 1
- 华为Mate30 鸿蒙3.0 弹窗申请权限,拒绝以后无法再次弹出,也无法弹窗提示,小米正常 HOT 1
- AppSettingsDialog 确定和取消的颜色在部分手机上是透明的 HOT 1
- Can you customize this box? I want to write one myself HOT 1
- As
- A
- onActivityResult回调权限成功,但是@AfterPermissionGranted(PERMISSIONS_REQUEST_CODE) public void onPermissionSuccess() {}不调用正常吗
- 发现在荣耀 50 pro
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easypermissions.