• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps READ_SMS permissions not working

draffodx

Lurker
Oct 6, 2009
8
0
Anyone else have trouble using the READ_SMS permission, I have placed it in my aps mainfest file along with all the other permissions but it doesn't appear to work.

My app crashes because of it Get the required permissions error.

In the apps persmissions screen it doesn't show up either.

very confusing, has anyone noticed anything similiar?

permissions_795.png
 
Depends.. are you trying to connect to the sms content provider and read stored sms messages already on the phone?

Or are you trying to process sms messages as they arrive? If its the latter you need the RECEIVE_SMS permission...

have that permission in there too.

I'm trying to read messages on the phone and it specifically asks for the READ_SMS permission which I already have in the manifest.

can post code on monday, away from my dev machine at the minute
 
Upvote 0
To help hopefully diagnose the problem here is my xml manifest file:

Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="cicero.org"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".TestApp"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".SettingsApp"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.SETTINGS" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <provider android:name=".CiceroContentProvider"
                        android:authorities="cicero.org.CiceroContentProvider"
                        android:multiprocess="true" />
                        
       <receiver android:name=".SMSApp">  
          <intent-filter>  
              <action android:name="android.provider.Telephony.SMS_RECEIVED" />  
           </intent-filter>  
       </receiver>  
       
    </application>
    <uses-sdk android:minSdkVersion="3" />
    
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
    <uses-permission android:name="android.permission.CALL_PHONE"/>
    <uses-permssion android:name="android.permission.SEND_SMS"/>
    <uses-permission android:name="android.permission.RECEIVE_SMS"/>
    <uses-permssion android:name="android.permission.READ_SMS"/>
    <uses-permssion android:name="android.permission.WRITE_SMS"/>
    
    
</manifest>

And here is the java code that requires the SMS_READ permission, which is clearly in the manifest file

Code:
// in onCreate()
    String url = "content://sms/"; 
            Uri uri = Uri.parse(url); 
            getContentResolver().registerContentObserver(uri, true, new MyContentObserver(handler)); 
        
    
    
    class MyContentObserver extends ContentObserver { 
        
        public MyContentObserver(Handler handler) { 
            
            super(handler); 
            
        }

    @Override public boolean deliverSelfNotifications() { 
        return false; 
        }

    @Override public void onChange(boolean arg0) { 
        super.onChange(arg0);
        
         Log.v("SMS", "Notification on SMS observer"); 
        
        Message msg = new Message();
        msg.obj = "xxxxxxxxxx";
        
        handler.sendMessage(msg);
        
        Uri uriSMSURI = Uri.parse("content://sms/");
        Cursor cur = getContentResolver().query(uriSMSURI, null, null,
                     null, null);
        cur.moveToNext();
        String protocol = cur.getString(cur.getColumnIndex("protocol"));
        if(protocol == null)
               Log.d("SMS", "SMS SEND"); 
        else
            Log.d("SMS", "SMS RECIEVE");        

    }

Anybody any ideas?
 
Upvote 0
<uses-permssion android:name="android.permission.READ_SMS"/>
<uses-permssion android:name="android.permission.WRITE_SMS"/>

Found another example and discovered the same copy/paste error in my file.

uses-permssion

uses-permission

Too funny. Mine works now. I wonder how many others out there copied the same example with the same misspelling?
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones