BroadcastReceiver's onReceive not firing on incoming sms - android

I am stuck for more than 6 hours, I have gone through every possible helpful post but no luck
The onReceive() method of BroadcastReceiver is not getting fired.
Below is the code of my MainAcitivty, Manifest and BroadCastReceiver.
This is code of my mainactivity
package com.example.luckydraw;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.telephony.SmsManager;
import android.util.Log;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
This is My broadcast reciever
package com.example.luckydraw;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;
public class Smsrcv extends BroadcastReceiver {
private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
private static final String TAG = "Smsrcv";
#Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Toast.makeText(context, "I re", Toast.LENGTH_LONG).show();
Log.i(TAG, "Intent recieved: " + intent.getAction());
String message="test message";
String PhoneNumber="03214304743";
SmsManager.getDefault().sendTextMessage(PhoneNumber, null, message, null, null);
if (intent.getAction() == SMS_RECEIVED) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[])bundle.get("pdus");
final SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
}
if (messages.length > -1) {
Log.i(TAG, "Message recieved: " + messages[0].getMessageBody());
}
}
}
}
}
And finally this is my manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.luckydraw"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".Smsrcv"
android:enabled="true"
android:exported="true"
>
<intent-filter android:priority="1000" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>

There are certain messaging applications e.g. GO SMS PRO etc which have broadcast recievers' intent fiters like
<intent-filter android:priority="2147483647" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
Here android:priority is 2147483647
This wasnt letting my app to catch System's broadcast !!
If you want to check all messaging applications' priorities on your device
use this
Intent intent = new Intent("android.provider.Telephony.SMS_RECEIVED");
List<ResolveInfo> infos = getPackageManager().queryBroadcastReceivers(intent, 0);
for (ResolveInfo info : infos) {
System.out.println("Receiver name:" + info.activityInfo.name + "; priority=" + info.priority);
}
SOLUTION
You should uninstall those with priority > 1000, to make your app work..

Related

How do I use Broadcast Receiver that toasts when an SMS is received?

This is the MainActivity.java:
package tagit.aj.com.broadcastreceiverforsms;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
This the MyReceiver class which includes the broadcast receiver's onReceive method. One of the methods used here is "deprecated" but I assume it does not create any problems in testing.
package tagit.aj.com.broadcastreceiverforsms;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;
public class MyReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Toast.makeText(context,"IncomingSms",Toast.LENGTH_SHORT).show();
// Retrieves a map of extended data from the intent.
final Bundle bundle = intent.getExtras();
try {
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
for (int i = 0; i < pdus.length; i++) {
SmsMessage messages = SmsMessage.createFromPdu((byte[]) pdus[i]);
String phoneNumber = messages.getDisplayOriginatingAddress();
String phone = phoneNumber;
String stringMessage = messages.getDisplayMessageBody();
int duration = Toast.LENGTH_LONG;
Log.i("Broadcasting", "Number" + phone + "Message" + stringMessage);
Toast toast = Toast.makeText(context, "senderNum: " + phone + ", message: " + stringMessage, duration);
toast.show();
} // end for loop
} // bundle is null
} catch (Exception e) {
Log.e("SmsReceiver", "Exception smsReceiver" + e);
}
}
}
The XML layout is:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="tagit.aj.com.broadcastreceiverforsms.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
And the AndroidManifest file is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tagit.aj.com.broadcastreceiverforsms">
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".MyReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"></action>
</intent-filter>
</receiver>
</application>
</manifest>
Please provide me with why this problem is occurring, and a solution (if any). And I'm running this app on Android KitKat.
I think his problem is that his code is not working, due to changes made in SMS Provider in Android 4.4
SMS Provider in Android 4.4

app working fine in emulator of android studio but not on real device - BroadcastReceiver

This is an app which toasts a received message and gives it a reply
when i tested with the emulator it is working fine but not on device
-----this is the MainActivity.java---------
package com.example.yj.example;
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
-------This is SmsReceiver.java-----------
package com.example.yj.example;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.widget.Toast;
public class SmsReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Bundle bundle=intent.getExtras();
if(bundle != null){
Object[] pdus= (Object[]) bundle.get("pdus");
String senderNumber=null;
for(int i=0; i<pdus.length; i++){
SmsMessage sms=SmsMessage.createFromPdu((byte[]) pdus[i]);
senderNumber = sms.getDisplayOriginatingAddress();
String message= sms.getDisplayMessageBody();
Toast.makeText(context, "From:" + senderNumber + " Message:" + message, Toast.LENGTH_LONG).show();
}
SmsManager smsManager=SmsManager.getDefault();
smsManager.sendTextMessage(senderNumber,null,"u r lucky!!!!! its finally working",null,null);
}
}
}
---------this is AndroidManifest.xml -----------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.yj.example" >
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
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=".SmsReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
</application>
</manifest>

start broadcastreceiver

Here I am trying to read the message and toast it I have seen various examples where there is a separate class that extends BroadcastReceiver but they have not mentioned how to start this class(do we use startactivity() or somthing else). I have posted the code that I dowladed through a link from O'Reilly's cookbook. I've tried to sms from ddms but it doesn't show toast of message. Any help is appreciated as this is my first time with BroadcastReceiver.
invitationSMSreciever.java
package com.SMS;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.sax.StartElementListener;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;
public class invitationSMSreciever extends BroadcastReceiver {
final String TAG = "BombDefusalApp";
#Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String message = "";
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i = 0; i < msgs.length; i++) {
msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
message = msgs[i].getMessageBody();
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
if (msgs[i].getMessageBody().equalsIgnoreCase("Invite")) {
// Intent myIntent = new Intent(MainMenu.this,
// com.bombdefusal.ReceivedSMSActivity.class);
Intent myIntent = new Intent();
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myIntent.setAction("com.example.helloandroid.INVITE");
context.startActivity(myIntent);
}
}
}
}
}
MainMenu
package com.SMS;
import com.SMS.R;
import android.app.Activity;
import android.os.Bundle;
public class MainMenu extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
ReceivedSMSActivity
package com.SMS;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import com.SMS.R;
public class ReceivedSMSActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startService(new Intent ("com.android.PLAY"));
setContentView(R.layout.invite);
}
public boolean onKeyDown(int keyCode, KeyEvent service) {
stopService(new Intent("com.bombdefusal.START_AUDIO_SERVICE"));
finish();
return true;
}
}
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.SMS" android:versionCode="1" android:versionName="1.0">
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".MainMenu" android:label="#string/app_name">
<intent-filter>
<action android:name="com.SMS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.SMS.ReceivedSMSActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="com.example.helloandroid.INVITE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<receiver android:name="com.SMS.invitationSMSreciever"
android:enabled="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
</application>
</manifest>
You have two options to do this:
Register you broadcast receiver statically in the AndroidManifest file. Thus, it will be called automatically.
Register you broadcast receiver dynamically in your code using registerReceiver() method. In this case, this method should be paired with unregisterReceiver() where you unregister your receiver.
Usually, if broadcast receiver is implemented as a separate class then it usually registered statically in AndroidManifest file. I guess in you case you should just add the following lines to your file:
<receiver android:name=".invitationSMSreciever" android:exported="true" >
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

Monitoring incoming SMS messages in Android

I have this program that will try to monitor incoming SMS messages. But when I tried to run my program in the emulator and I tried to send a SMS message, it works. But when I installed my program in my phone, its not working.
What is the problem?
And I want to run the program at the backend as well. How to do that?
BTW, below are the whole codes for this sample app.
Thanks
RJ
import java.io.BufferedWriter;
import java.io.FileWriter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;
public class MySMSMonitor extends BroadcastReceiver
{
private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";
#Override
public void onReceive(Context context, Intent intent)
{
if(intent!=null &&
intent.getAction()!=null &&
ACTION.compareToIgnoreCase(intent.getAction())==0)
{
Object[]pduArray= (Object[]) intent.getExtras().get("pdus");
SmsMessage[] messages = new SmsMessage[pduArray.length];
for (int i = 0; i<pduArray.length; i++) {
messages[i] = SmsMessage.createFromPdu ((byte[])pduArray [i]);
}
Log.d("MySMSMonitor","SMS Message Received.");
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="spy.Frandy.com"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="6" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".TelephonyDemo"
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=".MySMSMonitor"> <intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"/> </intent-filter>
</receiver>
</application>
</manifest>
import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class TelephonyDemo extends Activity
{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button sendBtn = (Button)findViewById(R.id.sendSmsBtn);
sendBtn.setOnClickListener(new OnClickListener(){
#Override public void onClick(View view) {
EditText addrTxt = (EditText)TelephonyDemo.this.findViewById(R.id.addrEditText);
EditText msgTxt = (EditText)TelephonyDemo.this.findViewById(R.id.msgEditText);
try {
sendSmsMessage(
addrTxt.getText().toString(),msgTxt.getText().toString());
Toast.makeText(TelephonyDemo.this, "SMS Sent",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(TelephonyDemo.this, "Failed to send SMS", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}});
}
#Override
protected void onDestroy() {
super.onDestroy();
}
private void sendSmsMessage(String address,String message)throws Exception {
SmsManager smsMgr = SmsManager.getDefault();
smsMgr.sendTextMessage(address, null, message, null, null);
}
}
I would simply insist you to use ContentObserver and register content://sms Uri and fetch the type of the SMS using
cusor.getString(cusor.getColumnIndex("type")); // 1 = SMS Received
// 2 = SMS Sent
Further you can easily get the required data from the cursor that you fetched. Here is a blog for the same.
I'm going to assume with the little detail you have provided that the reason it works on a emulator and not your actual phone; may be another conflicting app intercepting the messages before they are broadcasted to your app.
try adding android:priority="1000" to your intent-filter of your receiver in your apps manifest
(a thousand being whatever number you feel necessary, could be higher if needed)
<intent-filter android:priority="1000" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
more info on - intent-filter priority
Try This:
<receiver android:name=".MySMSMonitor"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="2">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

onReceive BroadcastReceiver crashing in debug

I am creating a sms forwarding app and and I am having a problem with my SmsListener class.
package sms.pack;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Environment;
import android.telephony.SmsMessage;
import android.util.Log;
public class SmsListener extends BroadcastReceiver{
private SharedPreferences preferences;
#Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")){
Bundle bundle = intent.getExtras(); //---get the SMS message passed in---
SmsMessage[] msgs = null;
String device = "15555215556";
String msg_from;
if (bundle != null){
//---retrieve the SMS message received---
try{
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for(int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
msg_from = msgs[i].getOriginatingAddress();
String msgBody = msgs[i].getMessageBody();
if (msg_from == device)
{
savedata(msgBody);
}
}
}catch(Exception e){
// Log.d("Exception caught",e.getMessage());
}
}
}
}
public void savedata(String data)
{
try {
File root = Environment.getExternalStorageDirectory();
if (root.canWrite()){
File gpxfile = new File(root, "smsfile.txt");
FileWriter gpxwriter = new FileWriter(gpxfile);
BufferedWriter out = new BufferedWriter(gpxwriter);
out.write(data);
out.close();
}
} catch (IOException e) {
Log.e(data,"Could not write file " + e.getMessage());
}
}
}
my activity class
package sms.pack;
import java.util.List;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class SMS_forwardActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void openInbox() {
String application_name = "com.android.mms";
try {
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
List<ResolveInfo> resolveinfo_list = this.getPackageManager()
.queryIntentActivities(intent, 0);
for (ResolveInfo info : resolveinfo_list) {
if (info.activityInfo.packageName
.equalsIgnoreCase(application_name)) {
launchComponent(info.activityInfo.packageName,
info.activityInfo.name);
break;
}
}
} catch (ActivityNotFoundException e) {
Toast.makeText(
this.getApplicationContext(),
"There was a problem loading the application: "
+ application_name, Toast.LENGTH_SHORT).show();
}
}
private void launchComponent(String packageName, String name) {
Intent launch_intent = new Intent("android.intent.action.MAIN");
launch_intent.addCategory("android.intent.category.LAUNCHER");
launch_intent.setComponent(new ComponentName(packageName, name));
launch_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(launch_intent);
}
public void startListening(View view)
{
Intent i = new Intent();
i.setClassName("sms.pack","sms.pack.SmsListener");
sendBroadcast(i);
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Listen"
android:onClick="startListening"/>
</LinearLayout>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sms.pack"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".SMS_forwardActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".listener.SmsListener">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
At the monent Activity class has a button that call the statListening class, which in turn starts the SmsListener class, which listens for a sms messsage to come from a certain number then saves the contents of the message to the SD card.
When I ran the project and clicked Listen, then sent the SMS from another VM phone, I found that there was no saved file in the SD card. So I decided to run the debug
When in debug mode I click the Listen button, then I send the message and I get an error in the debug
ActivityThread.handleReceiver(ActivityThread$handleReceiver)line1773
I can't figure out what is wrong with the code
specify the permissions in android manifest file as follows
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
</uses-permission>
and also specify priority for the listener so that the sms will be recieved to your app
<receiver android:name=".SmsReceiver" >
<intent-filter android:priority="50" >
<action
android:name="android.provider.Telephony.SMS_RECEIVED"
android:enabled="true" />
</intent-filter>
</receiver>
I suggest you place the receiver block in your manifest outside the application block.
And get rid of all the code related to starting the BroadcastReceiver - you don't need to start anything, Android will do it for you, since you registered the intent.
PVS

Categories

Resources