Android本地权限Androidmanifest SMS READ

组态:

  • 工作室1.3
  • API 23
  • 我正在学习Android,并开始致力于SMS阅读一个简单的项目。

    我已经在AndroidManifest.xml中的SMS_READ中添加了权限。 仍然在运行模拟器时,会抛出SMS_READ的错误权限拒绝。

    我不确定模拟器问题或API 23级权限是否更改?

    错误:

    Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider uri content://sms/inbox from pid=1900, uid=10058 requires android.permission.READ_SMS, or grantUriPermission()
                at android.os.Parcel.readException(Parcel.java:1599)
                at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
                at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
                at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
                at android.content.ContentResolver.query(ContentResolver.java:491)
                at android.content.ContentResolver.query(ContentResolver.java:434)
                at com.example.gunda.mysmsreadapp.MainActivity.fetchInbox(MainActivity.java:68)
                at com.example.gunda.mysmsreadapp.MainActivity.onCreate(MainActivity.java:36)
                at android.app.Activity.performCreate(Activity.java:6237)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                at android.app.ActivityThread.-wrap11(ActivityThread.java)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                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)
    

    这里是清单xml

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.gunda.mysmsreadapp" >
        <uses-permission android:name="android.permission.READ_SMS"/>
        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            android:exported="true"
    
            <activity
                android:name=".MainActivity"
                android:label="@string/app_name" >
    
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <!--<action android:name="android.provider.Telephony.READ_SMS" />-->
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
    
    </manifest>
    

    最后我找到了答案:API 23(android 6.o)需要不同类型的权限.....

    http://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en


    权限名称是READ_SMS,看起来你正在使用SMS_READ。

    链接地址: http://www.djcxy.com/p/29251.html

    上一篇: android local permission Androidmanifest SMS READ

    下一篇: Python module 'os' has no attribute 'mknod'