title: BroadcastReceiver can't detect/read sms
body: <p>I'm building an app that would read incoming SMS. But, my BroadcastReceiver class can't detect/read incoming SMS. I think my code is correct but still it's not working. </p>
  
  <p>Here's my code:</p>
  
  <p>[XML]</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.crashlocator.carlax.crashlocator"&gt;
  &lt;!--
       The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
       Google Maps Android API v2, but you must specify either coarse or fine
       location permissions for the 'MyLocation' functionality. 
  --&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.SEND_SMS" /&gt;
  &lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt;
  &lt;uses-permission android:name="android.permission.READ_SMS" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /&gt;
  &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity
          android:name=".MainActivity"
          android:theme="@android:style/Theme.NoTitleBar"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;!--
           The API key for Google Maps-based APIs is defined as a string resource.
           (See the file "res/values/google_maps_api.xml").
           Note that the API key is linked to the encryption key used to sign the APK.
           You need a different API key for each encryption key, including the release key that is used to
           sign the APK for publishing.
           You can define the keys for the debug and release targets in src/debug/ and src/release/. 
      --&gt;
      &lt;meta-data
          android:name="com.google.android.geo.API_KEY"
          android:value="@string/google_maps_key" /&gt;
  
      &lt;activity
          android:name=".MapsActivity"
          android:label="@string/title_activity_maps"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.default" /&gt;
          &lt;/intent-filter&gt;
  
      &lt;/activity&gt;
      &lt;activity android:name=".MainActivity2" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.default" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;receiver
          android:name=".SmsReceiver"
          android:exported="true" &gt;
          &lt;intent-filter android:priority="2147483647" &gt;
              &lt;action android:name="android.provider.Telephony.SMS_RECEIVED" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  
  
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>[JAVA CLASS]</p>
  
  <pre><code>public class SmsReceiver extends BroadcastReceiver {
  
  private static final String SMS_BUNDLE = "pdus";
  private String smsBody, address;
  
  @Override
  public void onReceive(Context context, Intent intent) {
  
      Toast.makeText(context,"Test",Toast.LENGTH_LONG);
  }
  
  
  
  public void showNotification(Context context) {
      Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
  
      PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
              new Intent(context, MapsActivity.class), 0);
  
      v.vibrate(500);
      Intent in = new Intent("SmsMessage.intent.MAIN").
              putExtra("get_msg", address + ":" + smsBody);
      context.sendBroadcast(in);
  
      NotificationCompat.Builder mBuilder =
              new NotificationCompat.Builder(context)
                      //.setSmallIcon(R.drawable.notif1)
                      .setContentTitle("Attention!")
                      .setContentText("Car crash occure.");
      mBuilder.setContentIntent(contentIntent);
      mBuilder.setDefaults(Notification.DEFAULT_SOUND);
      mBuilder.setAutoCancel(true);
      NotificationManager mNotificationManager =
              (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
      mNotificationManager.notify(1, mBuilder.build());
  
  }
  
  }
  </code></pre>