我只是想向自己发送一个简单的文字......当然例外是java.lang.SecurityException: Sending SMS message: uid 10263 does not have android.permission.SEND_SMS
这就是我的Manifest文件的样子
<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>
现在它位于Manifest
标记下..但即使我在application
标记下移动权限,我仍然会收到相同的错误。我很困惑..
答案 0 :(得分:5)
您需要做的就是:
<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>
答案 1 :(得分:1)
在使用-sdk之后添加您的权限:
<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>