Raju Kumar
Raju Kumar

Reputation: 1265

Android SMS_RECEIVED broadcastreceiver not getting called

The onreceived function in my bradcastreceiver is not being triggered.

I tested this by sending a sms message from different phones, but the log does not seem to show any Activity.

here is the receiver class

package nz.co.smstopc;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class SmsListener extends BroadcastReceiver{

    @Override
    public void onReceive(Context context, Intent intent) {
        //---get the SMS message passed in---
        Log.d("SmsListener", "new sms!!");
    }
}

And here is the minifest.xml

 <receiver android:name=".smstopc.SmsListener"> 
        <intent-filter>                                         
            <action android:name="android.provider.Telephony.SMS_RECEIVED" /> 
        </intent-filter> 
    </receiver>

This is the permission i have used.

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

I have tried everything to solve this problem. Did i miss something to add in minifest?

Upvotes: 1

Views: 1083

Answers (2)

confucius
confucius

Reputation: 13327

your package name in receiver may conflict with the package attribute in the manifest tag try this

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="your package name"
...
...
...
<receiver android:name="nz.co.smstopc.SmsListener"> 
        <intent-filter>                                         
            <action android:name="android.provider.Telephony.SMS_RECEIVED" /> 
        </intent-filter> 
    </receiver>

Upvotes: 0

krains
krains

Reputation: 93

I did it the same way, but my Manifest-File looks just a bit different:

<receiver android:name=".receiver.SmsBroadcastReceiver" >
     <intent-filter android:priority="99999999" >
          <action android:name="android.provider.Telephony.SMS_RECEIVED" />
     </intent-filter>
</receiver>

Upvotes: 1

Related Questions