Reputation: 3020
i am trying to receive sms from my application. i have made a ReceiveSms class which extends broadCastReceiver class. and i also override onReceive() . i added the permissions and register the reciever in the manifest. but when i send a sms using DDMS , my onRecieve not called. Why ? Thanks is advance. Here is my manifest and BroadCastReceiver.
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class ReceiveSms extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "One Message Received", Toast.LENGTH_LONG).show();
}
}
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.blogspot.uappmarket.sendingsms"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="6"
android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.blogspot.uappmarket.sendingsms.SendSms"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".ReceiveSms" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
Upvotes: 3
Views: 1147
Reputation: 132982
you will need to add android.permission.RECEIVE_SMS uses-permission in manifest to receive sms :
<uses-permission android:name="android.permission.RECEIVE_SMS" />
Upvotes: 3