SMS permissions?

Put your problem here if it does not fit any of the other categories.

SMS permissions?

Postby Draffodx » Fri Jan 15, 2010 1:33 pm

Hi all,

I keep getting the following error:

01-15 12:29:28.155: ERROR/DatabaseUtils(115): java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider uri content://sms from pid=1004, uid=10054 requires android.permission.READ_SMS


Even though I have the persmission READ_SMS in my manifest, I have tried it both outside the application tags and inside, neither way seems to work and the same error keeps popping up

Here is my manifest:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.      package="cicero.org"
  6.  
  7.      android:versionCode="1"
  8.  
  9.      android:versionName="1.0">
  10.  
  11.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  12.  
  13.         <activity android:name=".TestApp"
  14.  
  15.                  android:label="@string/app_name">
  16.  
  17.             <intent-filter>
  18.  
  19.                 <action android:name="android.intent.action.MAIN" />
  20.  
  21.                 <category android:name="android.intent.category.LAUNCHER" />
  22.  
  23.             </intent-filter>
  24.  
  25.         </activity>
  26.  
  27.         <activity android:name=".SettingsApp"
  28.  
  29.                  android:label="@string/app_name">
  30.  
  31.             <intent-filter>
  32.  
  33.                 <action android:name="android.intent.action.SETTINGS" />
  34.  
  35.                 <category android:name="android.intent.category.LAUNCHER" />
  36.  
  37.             </intent-filter>
  38.  
  39.         </activity>
  40.  
  41.                 <provider android:name=".CiceroContentProvider"
  42.  
  43.                                                 android:authorities="cicero.org.CiceroContentProvider"
  44.  
  45.                                                 android:multiprocess="true" />
  46.  
  47.                                                
  48.  
  49.            <receiver android:name=".SMSApp">  
  50.  
  51.           <intent-filter>  
  52.  
  53.               <action android:name="android.provider.Telephony.SMS_RECEIVED" />  
  54.  
  55.            </intent-filter>  
  56.  
  57.        </receiver>  
  58.  
  59.        
  60.  
  61.     </application>
  62.  
  63.     <uses-sdk android:minSdkVersion="3" />
  64.  
  65.     <uses-permssion android:name="android.permission.READ_SMS"/>
  66.  
  67.     <uses-permission android:name="android.permission.READ_CONTACTS"/>
  68.  
  69.         <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
  70.  
  71.         <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
  72.  
  73.         <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
  74.  
  75.         <uses-permission android:name="android.permission.WAKE_LOCK"/>
  76.  
  77.         <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
  78.  
  79.         <uses-permission android:name="android.permission.CALL_PHONE"/>
  80.  
  81.         <uses-permission android:name="android.permission.RECEIVE_SMS"/>
  82.  
  83.         <uses-permssion android:name="android.permission.WRITE_SMS"/>
  84.  
  85. </manifest>
Parsed in 0.007 seconds, using GeSHi 1.0.8.4


Anybody got any ideas if I'm missing something else or why the permission is not getting recognized in the manifest?


EDIT:

Just to add here is the permissions screen for the app and despite READ_SMS being in the manifest, it doesn't show up in the permissions screen for the application, very confusing
Attachments
permissions.png
permissions.png (18 KiB) Viewed 1617 times
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Top

Postby Draffodx » Mon Jan 18, 2010 10:11 am

Also here is the java code that requires the SMS_READ permission, which is clearly in the manifest but it still says it requires that permission when I run the code and it force closes my app


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  // in onCreate()
  2.  
  3.         String url = "content://sms/";
  4.  
  5.                 Uri uri = Uri.parse(url);
  6.  
  7.                 getContentResolver().registerContentObserver(uri, true, new MyContentObserver(handler));
  8.  
  9.                
  10.  
  11.    
  12.  
  13.    
  14.  
  15.     class MyContentObserver extends ContentObserver {
  16.  
  17.        
  18.  
  19.         public MyContentObserver(Handler handler) {
  20.  
  21.                
  22.  
  23.                 super(handler);
  24.  
  25.                
  26.  
  27.         }
  28.  
  29.  
  30.  
  31.     @Override public boolean deliverSelfNotifications() {
  32.  
  33.         return false;
  34.  
  35.         }
  36.  
  37.  
  38.  
  39.     @Override public void onChange(boolean arg0) {
  40.  
  41.         super.onChange(arg0);
  42.  
  43.        
  44.  
  45.          Log.v("SMS", "Notification on SMS observer");
  46.  
  47.        
  48.  
  49.         Message msg = new Message();
  50.  
  51.         msg.obj = "xxxxxxxxxx";
  52.  
  53.        
  54.  
  55.         handler.sendMessage(msg);
  56.  
  57.        
  58.  
  59.         Uri uriSMSURI = Uri.parse("content://sms/");
  60.  
  61.         Cursor cur = getContentResolver().query(uriSMSURI, null, null,
  62.  
  63.                      null, null);
  64.  
  65.         cur.moveToNext();
  66.  
  67.         String protocol = cur.getString(cur.getColumnIndex("protocol"));
  68.  
  69.         if(protocol == null)
  70.  
  71.                Log.d("SMS", "SMS SEND");
  72.  
  73.         else
  74.  
  75.                 Log.d("SMS", "SMS RECIEVE");        
  76.  
  77.  
  78.  
  79.     }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Postby Draffodx » Mon Jan 18, 2010 11:56 am

Found the problem!

Very embarrasing :oops: :oops:

Who can spot the stupid mistake? its in the manifest :roll:
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 19 guests