I have a manifers for my app like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ssh.com.smsassistant" >
<uses-permission android:name="android.permission.READ_SMS" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And when I try to read sms using following code:
Uri message = Uri.parse("content://sms/");
ContentResolver cr = mActivity.getContentResolver();
Cursor c = cr.query(message, null, null, null, null);
it fails with the following exception:
Caused by: java.lang.SecurityException: Permission Denial:
reading com.android.providers.telephony.SmsProvider uri content://sms/
from pid=6670, uid=10059 requires android.permission.READ_SMS, or
grantUriPermission()
Any ideas, guys?