Sms Permissions not working. No matter where I put the permission tag

[亡魂溺海] 提交于 2019-12-24 05:05:08

问题


I'm just trying to send a simple text to my self.. of course the exception is java.lang.SecurityException: Sending SMS message: uid 10263 does not have android.permission.SEND_SMS

This is what my Manifest file looks like

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.homesafe"
    android:versionCode="1"
    android:versionName="1.0" 
    android:permission="android.permission.SEND_SMS">

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19"
         />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"

        >
        <activity
            android:name="com.example.homesafe.MainActivity"
            android:label="@string/app_name"

             >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Right now it is under the Manifest tag.. but even if I move the permission under the application tag, I still get the same error. I'm confused..


回答1:


All you need to do is this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.homesafe"
    android:versionCode="1"
    android:versionName="1.0">

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19"
         />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"

        >
        <activity
            android:name="com.example.homesafe.MainActivity"
            android:label="@string/app_name"

             >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>



回答2:


Add Your permissions after use-sdk like that:

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.homesafe"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19"/>

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <activity
            android:name="com.example.homesafe.MainActivity"
            android:label="@string/app_name"

             >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


来源:https://stackoverflow.com/questions/23210056/sms-permissions-not-working-no-matter-where-i-put-the-permission-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!