Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安卓 权限检测报错 #323

Closed
kmlidc opened this issue Aug 21, 2018 · 7 comments
Closed

安卓 权限检测报错 #323

kmlidc opened this issue Aug 21, 2018 · 7 comments

Comments

@kmlidc
Copy link

kmlidc commented Aug 21, 2018

Redmi Note 4X android 7.0

java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{fc6f588 16179:com.hiwoniu.weiling/u0a211} (pid=16179, uid=10211) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
at android.os.Parcel.readException(Parcel.java:1683)
at android.os.Parcel.readException(Parcel.java:1636)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:4256)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:5651)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2281)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1531)
at android.content.ContentResolver.query(ContentResolver.java:516)
at android.content.ContentResolver.query(ContentResolver.java:473)
at com.rt2zz.reactnativecontacts.ContactsProvider.getContacts(ContactsProvider.java:170)
at com.rt2zz.reactnativecontacts.ContactsManager$1.run(ContactsManager.java:88)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:760)

@morenoh149
Copy link
Owner

please follow https://github.com/rt2zz/react-native-contacts#android-permissions specifically from ProcessRecord{fc6f588 16179:com.hiwoniu.weiling/u0a211} (pid=16179, uid=10211) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS

@JslinSir
Copy link

@morenoh149 How are Chinese characters sorted? Android getAll() api

@JslinSir
Copy link

#328

@dahudson88
Copy link

@kmlidc were you able to get this fixed? I have done everything to get tis to work:

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.app">

    <uses-permission android:name="android.permission.READ_CONTACTS"/>...

Per the documentation on permissions with Android M and beyond, found here I am suppose to call the request() function from PermissionsAndroid. So in App.js I have added the following lines:

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
    };

  }
  async  componentWillMount() {
    await this.requestContactsPermission();
}

async requestContactsPermission() {
    try {
        const granted = await PermissionsAndroid.request(
            PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
            {
                'title': 'VDMC',
                'message': 'Access Contacts for messages.'
            }
        )

        console.log('ANDROID PERMISSION', granted)

        if ( granted === PermissionsAndroid.RESULTS.GRANTED) {
            console.log("You can use the location")
            alert("You can use the location");
        } else {
            console.log("location permission denied")
            alert("Location permission denied");
        }
    } catch (err) {
        console.warn(err)
    }
}...

When I run this code on the Android Studio Emulator I see the alerts, and console messages. How ever when on a real device I get the same stack trace that you are getting. Any help would be appreciated. thanks.

@dahudson88
Copy link

@morenoh149
Copy link
Owner

@morenoh149
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants