-4

I tried popping a Toast when the user I getting an SMS message. for some reason, the Toast doesn't show I have every permission I need in the manifest file

the receiver in manifest

the code:

   public class IncomingSMS extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context,"don't let your SMS keep you away from your missions goal",Toast.LENGTH_LONG).show();
    }
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Niv Peretz
  • 19
  • 3
  • There are multiple causes for this, one of which is that your app is lower broadcast priority than other installed SMS apps. – Aloha Jun 25 '17 at 09:22

1 Answers1

0

Add the following permissions in the manifest file.
<uses-permission android:name="android.permission.READ_SMS"/> Use like this

<receiver
android:name=".SmsBroadReceiver"
android:permission="android.permission.BROADCAST_SMS">
   <intent-filter>
   <action android:name="android.provider.Telephony.SMS_RECEIVED" 
   />
   </intent-filter>
</receiver>`
Siva agarwal
  • 97
  • 1
  • 8