READ_SMS permissions not working


Last Updated:

  1. draffodx

    draffodx Member This Topic's Starter

    Joined:
    Oct 6, 2009
    Messages:
    8
    Likes Received:
    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?

    [​IMG]
     

    Advertisement
  2. KeithG

    KeithG Well-Known Member

    Joined:
    Nov 15, 2009
    Messages:
    103
    Likes Received:
    3
    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...
     
  3. draffodx

    draffodx Member This Topic's Starter

    Joined:
    Oct 6, 2009
    Messages:
    8
    Likes Received:
    0
    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
     
  4. draffodx

    draffodx Member This Topic's Starter

    Joined:
    Oct 6, 2009
    Messages:
    8
    Likes Received:
    0
    To help hopefully diagnose the problem here is my xml manifest file:

    Code (Text):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    3.       package="cicero.org"
    4.       android:versionCode="1"
    5.       android:versionName="1.0">
    6.     <application android:icon="@drawable/icon" android:label="@string/app_name">
    7.         <activity android:name=".TestApp"
    8.                   android:label="@string/app_name">
    9.             <intent-filter>
    10.                 <action android:name="android.intent.action.MAIN" />
    11.                 <category android:name="android.intent.category.LAUNCHER" />
    12.             </intent-filter>
    13.         </activity>
    14.         <activity android:name=".SettingsApp"
    15.                   android:label="@string/app_name">
    16.             <intent-filter>
    17.                 <action android:name="android.intent.action.SETTINGS" />
    18.                 <category android:name="android.intent.category.LAUNCHER" />
    19.             </intent-filter>
    20.         </activity>
    21.         <provider android:name=".CiceroContentProvider"
    22.                         android:authorities="cicero.org.CiceroContentProvider"
    23.                         android:multiprocess="true" />
    24.                        
    25.        <receiver android:name=".SMSApp">  
    26.           <intent-filter>  
    27.               <action android:name="android.provider.Telephony.SMS_RECEIVED" />  
    28.            </intent-filter>  
    29.        </receiver>  
    30.        
    31.     </application>
    32.     <uses-sdk android:minSdkVersion="3" />
    33.    
    34.     <uses-permission android:name="android.permission.READ_CONTACTS"/>
    35.     <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
    36.     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    37.     <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
    38.     <uses-permission android:name="android.permission.WAKE_LOCK"/>
    39.     <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
    40.     <uses-permission android:name="android.permission.CALL_PHONE"/>
    41.     <uses-permssion android:name="android.permission.SEND_SMS"/>
    42.     <uses-permission android:name="android.permission.RECEIVE_SMS"/>
    43.     <uses-permssion android:name="android.permission.READ_SMS"/>
    44.     <uses-permssion android:name="android.permission.WRITE_SMS"/>
    45.    
    46.    
    47. </manifest>
    And here is the java code that requires the SMS_READ permission, which is clearly in the manifest file

    Code (Text):
    1. // in onCreate()
    2.     String url = "content://sms/";
    3.             Uri uri = Uri.parse(url);
    4.             getContentResolver().registerContentObserver(uri, true, new MyContentObserver(handler));
    5.        
    6.    
    7.    
    8.     class MyContentObserver extends ContentObserver {
    9.        
    10.         public MyContentObserver(Handler handler) {
    11.            
    12.             super(handler);
    13.            
    14.         }
    15.  
    16.     @Override public boolean deliverSelfNotifications() {
    17.         return false;
    18.         }
    19.  
    20.     @Override public void onChange(boolean arg0) {
    21.         super.onChange(arg0);
    22.        
    23.          Log.v("SMS", "Notification on SMS observer");
    24.        
    25.         Message msg = new Message();
    26.         msg.obj = "xxxxxxxxxx";
    27.        
    28.         handler.sendMessage(msg);
    29.        
    30.         Uri uriSMSURI = Uri.parse("content://sms/");
    31.         Cursor cur = getContentResolver().query(uriSMSURI, null, null,
    32.                      null, null);
    33.         cur.moveToNext();
    34.         String protocol = cur.getString(cur.getColumnIndex("protocol"));
    35.         if(protocol == null)
    36.                Log.d("SMS", "SMS SEND");
    37.         else
    38.             Log.d("SMS", "SMS RECIEVE");        
    39.  
    40.     }
    Anybody any ideas?
     
  5. draffodx

    draffodx Member This Topic's Starter

    Joined:
    Oct 6, 2009
    Messages:
    8
    Likes Received:
    0
    Found the problem!

    Very embarrasing [​IMG] [​IMG]

    Who can spot the stupid mistake? its in the manifest [​IMG]
     
  6. Digitalman42

    Digitalman42 Member

    Joined:
    Jun 6, 2010
    Messages:
    6
    Likes Received:
    0
    I'm having the problem. This is an old thread, but no answer and no, I don't see the problem. Anyone care to share? It's not obvious to me what the problem is.
     
  7. Digitalman42

    Digitalman42 Member

    Joined:
    Jun 6, 2010
    Messages:
    6
    Likes Received:
    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?
     

Share This Page

Loading...