Reputation: 111
I am attempting to create a simple app that can send a text message from my android cell phone to another cell phone, but at the moment I am using the emulators. The problem I am getting is that the app keeps getting stopped unexpectedly.
I looked at my logCat and I notice I get this line
12-13 23:36:49.611: ERROR/AndroidRuntime(29001): java.lang.SecurityException: Sending SMS message: User 10131 does not have android.permission.SEND_SMS.
But this confuses me because in my AndroidManifest.xml I have this code
<?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>
I did a single step as well and I crash at this line
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
with the arguments as follows
phoneNumber: My Cell phone's number as a string in the format "XXXXXXXXXX"
null: null
message: "testing"
sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
With SENT being
String SENT = "SMS_SENT";
and DELIVERED being
String DELIVERED = "SMS_DELIVERED";
I have no idea what to do now. I have googled and I didn't see anyone else with my problem.
Any help is appreciated! Thanks, Chris
Upvotes: 1
Views: 6093
Reputation: 234795
The <uses-permission ...>
tags need to be under the <manifest>
tag, not the <application>
tag.
Upvotes: 4