outgoing SMS issued with Permission Denial
<p>I want to log all the send sms and following the code below</p>

<p>SMSObserver class</p>

<pre><code>public class ServiceObserver extends ContentObserver {
private Context mContext;

//private String contactId = "", contactName = "";
private String smsBodyStr = "", phoneNoStr = "";
private long smsDatTime = System.currentTimeMillis();
static final Uri SMS_STATUS_URI = Uri.parse("content://sms/out");

public ServiceObserver(Handler handler, Context ctx) {
    super(handler);
    mContext = ctx;
}

public boolean deliverSelfNotifications() {
    return true;
}
public void onChange(boolean selfChange) {
    try{
        //Log.e("Info","Notification on SMS observer");
        Cursor sms_sent_cursor = mContext.getContentResolver().query(SMS_STATUS_URI, null, null, null, null);
        if (sms_sent_cursor != null) {
            if (sms_sent_cursor.moveToFirst()) {
                String protocol = sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("protocol"));
                Log.e("Info","protocol : " + protocol);
                int type = sms_sent_cursor.getInt(sms_sent_cursor.getColumnIndex("type"));
                    Log.e("Info","SMS Type : " + type);
                    // for actual state type=2
                    if(type == 2){
                        Log.e("Info","Id : " + sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("_id")));
                        Log.e("Info","Thread Id : " + sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("thread_id")));
                        Log.e("Info","Address : " + sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("address")));
                        Log.e("Info","Person : " + sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("person")));
                        Log.e("Info","Date : " + sms_sent_cursor.getLong(sms_sent_cursor.getColumnIndex("date")));
                        Log.e("Info","Read : " + sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("read")));
                        Log.e("Info","Status : " + sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("status")));
                        Log.e("Info","Type : " + sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("type")));
                        Log.e("Info","Rep Path Present : " + sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("reply_path_present")));
                        Log.e("Info","Subject : " + sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("subject")));
                        Log.e("Info","Body : " + sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("body")));
                        Log.e("Info","Err Code : " + sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("error_code")));

                        smsBodyStr = sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("body")).trim();
                        phoneNoStr = sms_sent_cursor.getString(sms_sent_cursor.getColumnIndex("address")).trim();
                        smsDatTime = sms_sent_cursor.getLong(sms_sent_cursor.getColumnIndex("date"));

                        Log.e("Info","SMS Content : "+smsBodyStr);
                        Log.e("Info","SMS Phone No : "+phoneNoStr);
                        Log.e("Info","SMS Time : "+smsDatTime);
                    }
                }
            }
        }
        else
            Log.e("Info","Send Cursor is Empty");
    }
    catch(Exception sggh){
        Log.e("Error", "Error on onChange : "+sggh.toString());
    }
    super.onChange(selfChange);
}
</code></pre>

<p>}</p>

<p>And on the main activity </p>

<pre><code>ServiceObserver smsSentObserver = new ServiceObserver(new Handler(), this);
this.getContentResolver().registerContentObserver(SMS_STATUS_URI, true, smsSentObserver);
</code></pre>

<p>And followed permission have been added on Manifest file</p>

<pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.sms"
android:versionCode="1"
android:versionName="1.0" &gt;

&lt;uses-sdk android:minSdkVersion="8" /&gt;

&lt;uses-permssion android:name="android.permission.READ_SMS"/&gt;
&lt;uses-permssion android:name="android.permission.WRITE_SMS" /&gt;
    &lt;uses-permission android:name="android.permission.RECEIVE_SMS"&gt;&lt;/uses-permission&gt;    
    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;    
&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
&lt;application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" &gt;
    &lt;activity
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar"
        android:name="com.test.sms.mainactivity" &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="com.test.sms.ServiceReceiver"&gt; 
        &lt;intent-filter&gt; 
            &lt;action android:name="android.provider.Telephony.SMS_RECEIVED" /&gt; 
            &lt;action android:name="android.net.conn.CONNECTIVITY_CHANGE"/&gt;                
        &lt;/intent-filter&gt; 
    &lt;/receiver&gt;        
&lt;/application&gt;
</code></pre>

<p></p>

<p>But after tried to send the sms from first emulator to second till got the permission error like this </p>

<p>*<strong>Error on onChange : java.lang.SecurityException: Permission Denial: opening provider com.android.providers.telephony.SmsProvider....requires android.permission.READ_SMS or android.permission.WRITE_SMS*</strong></p>

<p>Anybody can help please..... thank you...</p>
