Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android.provider.Telephony.SMS_RECEIVED not available

I'm trying to create a new SMS receive listner.

I have googled the problem and all I found was it requires

android.provider.Telephony.SMS_RECEIVED

but it doesnt exist in android 2.2

how to listen to new incoming messages is my question.!

like image 869
Shardul Avatar asked Sep 21 '10 12:09

Shardul


2 Answers

You are looking for android.provider.Telephony.SMS_RECEIVED_ACTION that corresponds to string value android.provider.Telephony.SMS_RECEIVED.

public static final String SMS_RECEIVED_ACTION =
                "android.provider.Telephony.SMS_RECEIVED";

Check out this question on how to do it: BroadcastReceiver + SMS_RECEIVED

like image 101
Maciej Pigulski Avatar answered Nov 12 '22 00:11

Maciej Pigulski


I am using this to register this broadcast

IntentFilter f=new IntentFilter();
    f.addAction(Telephony.Sms.Intents.SMS_RECEIVED_ACTION);
    this.registerReceiver(c, f);

or 2nd way could be as of below.

by the way u are doing and don't forget using android.provider.Telephony.SMS_RECEIVED as a string "android.provider.Telephony.SMS_RECEIVED" as it's a intent through which you are receiving SMS.

and both approaches working on minsdk 19 and (target can be >=26).

IntentFilter f=new IntentFilter();
    f.addAction("android.provider.Telephony.SMS_RECEIVED");
    this.registerReceiver(c, f);
like image 1
Ankit Bhardwaj Avatar answered Nov 12 '22 00:11

Ankit Bhardwaj