'Telephony.SMS_RECEIVED filter invoked selectively
I need to read text from incoming SMS and, as from title, I'm facing a strange behaviour: filter is correctly invoked when testing in android emulator and, on real phone, when using an SMS web service but not if SMS comes from another phone; below my code.
MANIFEST
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
Of course permission is granted for all of them.
BROADCAST RECEIVER
public class SmsNotificationReceiver extends BroadcastReceiver {
private static final String TAG = "[SmsNotificationReceiver]";
public SmsNotificationReceiver() {}
@Override
public void onReceive(Context context, @NonNull Intent intent) {
String action = intent.getAction();
if (TextUtils.isEmpty(action)) { return; }
Log.i(TAG, "Action: " + action);
}
}
RECEIVER REGISTRATION
IntentFilter filter = new IntentFilter();
filter.addAction("android.provider.Telephony.SMS_RECEIVED");
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
BroadcastReceiver smsReceiver = new SmsNotificationReceiver();
registerReceiver(smsReceiver, filter);
Anything wrong I'm doing here? Does anyone met similar behaviour and solved it? If so please kindly address me to recognize what's wrong? Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
