Receiving Sms message

I am trying to get sms from my application. I made a ReceiveSms class that extends the broadCastReceiver class. and i also override onReceive (). I added permissions and registered the receiver in the manifest. but when i send sms using DDMS my onRecieve is not called. What for? Thanks in 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>

      

+3


source to share


1 answer


you will need to add android.permission.RECEIVE_SMS uses-permission in manifest to receive sms:



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

      

+3


source







All Articles