title: Permission Denial: broadcasting Intent android.provider.Telephony.SMS_RECEIVED
body: <p>Hello i am new to Android, I'm getting this problem even after having the required SMS permissions inside my manifest file. I tried a couple of ways but it doesn't work anymore got any idea? </p>
  
  <p>AndroidManifest.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.example.phonefinder2"
          android:versionCode="1"
      android:versionName="1.0"&gt;
      &lt;uses-sdk android:minSdkVersion="8" /&gt;
  
          &lt;uses-permission android:name="android.permission.ACCESS_GPS" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_LOCATION" /&gt;    
     &lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt;
     &lt;uses-permission android:name="android.permission.READ_SMS" /&gt;
  
      &lt;application android:icon="@drawable/ic_launcher"&gt;
  
  
          &lt;activity android:name=".PhoneFinder" android:label="@string/app_name"&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;receiver android:name=".FinderReceiver" android:enabled="true" android:exported="false" android:permission="android.permission.RECEIVE_SMS"&gt; 
              &lt;intent-filter &gt; 
                  &lt;action android:name="android.provider.Telephony.SMS_RECEIVED" android:priority="999"/&gt; 
              &lt;/intent-filter&gt; 
          &lt;/receiver&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt; 
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>07-19 19:23:25.915: D/SntpClient(66): request time failed: java.net.SocketException: Address family not supported by protocol
  07-19 19:23:29.444: W/ActivityManager(66): Permission denied: checkComponentPermission() reqUid=10042
  07-19 19:23:29.454: W/ActivityManager(66): Permission Denial: broadcasting Intent { act=android.provider.Telephony.SMS_RECEIVED (has extras) } from com.android.phone (pid=124, uid=1001) requires android.permission.RECEIVE_SMS due to receiver com.example.phonefinder2/com.example.phonefinder2.FinderReceiver
  07-19 19:23:29.544: V/Telephony(235): getOrCreateThreadId uri: content://mms-sms/threadID?recipient=83380222
  07-19 19:23:29.616: V/Telephony(235): getOrCreateThreadId cursor cnt: 1
  07-19 19:23:30.126: D/Mms:app(235): getSmsNewMessageNotificationInfo: count=19, first addr=83380222, thread_id=1
  07-19 19:23:30.194: W/NotificationService(66): STOP command without a player
  07-19 19:23:30.305: D/MediaPlayer(66): Couldn't open file on client side, trying server side
  07-19 19:23:30.334: E/MediaPlayerService(34): Couldn't open fd for content://settings/system/notification_sound
  07-19 19:23:30.334: E/MediaPlayer(66): Unable to to create media player
  07-19 19:23:30.354: W/NotificationService(66): error loading sound for content://settings/system/notification_sound
  07-19 19:23:30.354: W/NotificationService(66): java.io.IOException: setDataSource failed.: status=0x80000000
  07-19 19:23:30.354: W/NotificationService(66):  at android.media.MediaPlayer.setDataSource(Native Method)
  07-19 19:23:30.354: W/NotificationService(66):  at android.media.MediaPlayer.setDataSource(MediaPlayer.java:716)
  07-19 19:23:30.354: W/NotificationService(66):  at android.media.MediaPlayer.setDataSource(MediaPlayer.java:671)
  07-19 19:23:30.354: W/NotificationService(66):  at com.android.server.NotificationPlayer$CreationAndCompletionThread.run(NotificationPlayer.java:88)
  </code></pre>
  
  <p>FinderReceiver.java:</p>
  
  <pre><code>package com.example.phonefinder2;
  
  import android.app.Notification;   
  import android.app.NotificationManager;   
  import android.app.PendingIntent;   
  import android.content.BroadcastReceiver;   
  import android.content.Context;   
  import android.content.Intent;   
  import android.content.SharedPreferences;   
  import android.location.Location;   
  import android.location.LocationManager;   
  import android.os.Bundle;   
  import android.telephony.SmsManager;   
  import android.telephony.SmsMessage;   
  import android.util.Log;
  import android.widget.Toast;
  
  public class FinderReceiver extends BroadcastReceiver {
      private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
      private static final String TAG = "Logging Activity";
  
      Context context;   
      @Override    
      public void onReceive(Context context, Intent intent) {  
          Log.v(TAG, "New Broadcast Receiver");
          this.context = context;   
          SharedPreferences passwdfile = context.getSharedPreferences(    
                  PhoneFinder.PASSWORD_PREF_KEY, 0); 
  
          Log.v(TAG, PhoneFinder.PASSWORD_PREF_KEY);
  
          String correctMd5 = passwdfile.getString(PhoneFinder.PASSWORD_PREF_KEY,    
                  null);    
  
          Log.v(TAG, correctMd5);
  
          if (correctMd5 != null) {    
              Log.v(TAG, "MD5 is not null");
  
              if (intent.getAction().equals(SMS_RECEIVED)) {
                Log.v(TAG, "Intent SMS RECEIVED success");
                Bundle bundle = intent.getExtras();   
                if (bundle != null) {
                Object pdus[] = (Object[]) bundle.get("pdus");
                SmsMessage smsMessage[] = new SmsMessage[pdus.length];   
  
  //              for(int i = 0; i &lt; smsMessage.length; i++)
                for(int i = 0; i &lt; pdus.length; i++) {   
                    smsMessage[i] = SmsMessage.createFromPdu((byte[])pdus[i]);   
                  if (smsMessage[i].getMessageBody().contains("RING:")) {    
                      String[] tokens = smsMessage[i].getMessageBody().split(":");    
                      if (tokens.length &gt;= 2) {    
                          String md5hash = PhoneFinder.getMd5Hash(tokens[1]);    
  
                          if (correctMd5.equals(md5hash)) {    
  /*                            String to = smsMessage[i].getOriginatingAddress (); 
                              SmsManager sm = SmsManager.getDefault(); 
  
                               sm.sendTextMessage (to, null, "success!", null, null);
                              NotificationManager nm =  
                                  (NotificationManager) context.getSystemService (Context.NOTIFICATION_SERVICE); 
                              Notification notification = new Notification(android.R.drawable.ic_dialog_info, "Alert", System.currentTimeMillis());
                              PendingIntent contentIntent = PendingIntent.getActivity (context, 0, new Intent (context, PhoneFinder.class), 0);
                              notification.setLatestEventInfo (context, "GPS address", "You have been detected", contentIntent);
                              nm.notify (R.string.service_start, notification);*/
                              this.abortBroadcast();
                              Toast toast = Toast.makeText(context, "Ring success!", Toast.LENGTH_LONG); 
                              toast.show();
                          }    
                      }    
                  } 
                  }   
              }    
      }
          }
  }    
  }
  </code></pre>