Comments (10)
but when i deny any permission, app crashes with security exception. did i missed anything.?
from ask.
It worked . nice.
from ask.
here Ask.on(getApplicationContext())
pass activity reference Ask.on(this)
from ask.
can you post the stacktrace?
from ask.
btw, did you add the requested permissions in manifest file?
from ask.
java.lang.RuntimeException: Unable to start receiver com.vistrav.ask.Ask$Receiver: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{c565248 17981:com.root5solutions.myapplication/u0a61} (pid=17981, uid=10061) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2732)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{c565248 17981:com.root5solutions.myapplication/u0a61} (pid=17981, uid=10061) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
at android.os.Parcel.readException(Parcel.java:1599)
at android.os.Parcel.readException(Parcel.java:1552)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:3550)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:4778)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2018)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1468)
at android.content.ContentResolver.query(ContentResolver.java:475)
at android.content.ContentResolver.query(ContentResolver.java:434)
at com.root5solutions.myapplication.MainActivity$1.granted(MainActivity.java:48)
at com.vistrav.ask.Ask$Receiver.onReceive(Ask.java:87)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2725)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
from ask.
My manifest
`
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
`
from ask.
you need to add these requested permission into your AndroidManifest.xml file check here for examle
from ask.
no its not the problem. i think the problem is whenever i press deny permission button, it redirects to method void granted
. there the code works without permission and finally endup in security exception
(because permission is not given yet,but still it goes to granted
method)
from ask.
I know why
the method public void granted(List<String> permissions)
will be called even if permission is denied but the list of permissions will be empty, you need to check what list if the desired permission has been granted by user, if yer the permission list will contain that permission else it will be in public void denied(List<String> permissions)
permission list.
to avoid this error you need to put if condition in public void granted(List<String> permissions)
and if particular permission granted then you can go ahead to check your logic. you can do something like
@Override
public void granted(List<String> permissions) {
if(permissions.contains(Manifest.permission.GET_ACCOUNTS)){
// get account granted and put your logic here
}
if(permissions.contains(Manifest.permission.READ_CONTACTS)){
// CONTACTS granted and put your logic here
}
}
from ask.
Related Issues (20)
- Failed to resolve error HOT 5
- Add listener "onFinished" HOT 2
- Rational message comes twice when single permission given HOT 3
- Cannot click on 'Allow' for permission HOT 2
- Crashing with my AppCompatActivity HOT 2
- Support Fragment HOT 5
- Memory Leak : It holds reference to the Activity HOT 3
- Added it on my first activity and it closes the app when it is first shown
- Some time activity crashes ("Caused by: java.lang.NullPointerException at com.vistrav.ask.Ask.getAnnotation Method(Ask.java:197)) HOT 4
- Manifest merger failed with multiple errors, see logs
- Android UI/Espresso test recording/playing HOT 1
- Reprompt permission check after user denies HOT 1
- Standard Fragment support HOT 1
- Permission callbacks not working (kotlin) HOT 1
- An activity flickers just before the launcher activity HOT 3
- Android 8.0 HOT 4
- denied branch gets called if with permission granted HOT 3
- Disable rtl HOT 3
- Rationals are not working in your code HOT 6
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 ask.