我試圖創建一個簡單的應用程序,可以從我的android手機發送短信到另一個手機,但此刻我正在使用模擬器。我得到的問題是應用程序意外停止。發送短信錯誤Android
我看着我的logcat,我發現我得到這一行
12-13 23:36:49.611:ERROR/AndroidRuntime(29001):java.lang.SecurityException異常:發送短信:用戶10131沒有android.permission.SEND_SMS。
但是,這讓我困惑,因爲在我的AndroidManifest.xml我有這樣的代碼
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.learn2develop.SMSMessaging"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".SMS"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
</application>
</manifest>
我做一個單一的步驟,以及和我在這行崩潰
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
的論據如下
電話號碼:我的手機空
消息::手機的作爲格式 「XXXXXXXXXX」
空字符串號碼 「測試」
sentPI = PendingIntent.getBroadcast(此,0, 新意圖(SENT) ,0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this,0, new Intent(DELIVERED),0);
隨着SENT是
字符串SENT = 「SMS_SENT」;
並輸送被
字符串DELIVERED = 「SMS_DELIVERED」;
我不知道現在該做什麼。我GOOGLE了,我沒有看到任何人與我的問題。
任何幫助表示讚賞! 謝謝, 克里斯
非常感謝你非常非常!我花了很多時間試圖找出這個問題。這對我看到的每個網站都有標記下的標記都沒有幫助。 –
2011-12-14 05:20:51