notification for sms sending

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

notification for sms sending

Postby saif_zeenwala » Tue Nov 24, 2009 10:00 am

hi guys

M working on sms and want notification when any one sends sms from mobile.

note: I am not going to send sms from my application, sms will be send by using normal sms application in a default messaging package

just like for incoming sms we have intent filter available

<action android:name="android.provider.Telephony.SMS_RECEIVED" />

is there any filter avaialble for sms sending ????


please help it is very urgent
saif_zeenwala
Junior Developer
Junior Developer
 
Posts: 15
Joined: Mon Nov 02, 2009 7:40 am

Top

Postby saif_zeenwala » Tue Nov 24, 2009 1:31 pm

hi guys


I got some thing on the top of my issue (getting notification on sending sms)


I have found below mentioned code

class SMSHandler extends Handler
{
public void handleMessage(Message msg)
{
//Handle message
Log.i("DEBUG","SMSHandler const");
}
}


class SMSObserver extends ContentObserver
{
private Handler m_handle = null;
Context t;

public SMSObserver(Handler handle, Context t)
{
super(handle);
this.t=t;
m_handle = handle;
Log.i("DEBUG","SMSObserver const");
}

public void onChange(boolean bSelfChange)
{
super.onChange(bSelfChange);

Log.i("DEBUG","onChange()");
try{
//Send message o Activity
Message msg = new Message();
msg.obj = "xxxxxxxxxx";
// m_handle.sendMessage(msg);

Uri uriSMSURI = Uri.parse("content://sms");
Cursor cur = t.getContentResolver().query(uriSMSURI, null, null, null, null);
cur.moveToNext();
String protocol = cur.getString(cur.getColumnIndex("protocol"));
Log.i("DEBUG","protocol:::"+protocol);
// if(protocol == null)
// onSMSSend();
// else
// onSMSReceive();

}catch(Exception e){
Log.i("DEBUG","eeee::"+e);
}



}



and calling blow lines in my activity's oncreate()

ContentResolver contentResolver = getContentResolver();
Handler handler = new SMSHandler();
ContentObserver m_SMSObserver = new SMSObserver(handler,this);
contentResolver.registerContentObserver(Uri.parse("content://sms/"),
true, m_SMSObserver);

I am getting notification when i send sms from emulator and onchange() gets called

but m getting permission exception in my code although i have added

<uses-permssion android:name="android.permission.READ_SMS" />


permission to my manifest file but still getting following error


java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider uri content://sms from pid=712, uid=10027 requires android.permission.READ_SMS


is there any other permission required

please help
saif_zeenwala
Junior Developer
Junior Developer
 
Posts: 15
Joined: Mon Nov 02, 2009 7:40 am

Top

Return to Other Coding-Problems

Who is online

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