[android-developers] Re: How to listen for changes on Calls.CallLog
hi Donal,
this is what i have done for sms
protected void listeneNativeInbox() {
String url = "content://sms/";
Uri uri = Uri.parse(url);
context.getContentResolver().registerContentObserver(CallLog.Calls.CONTENT_URI,
true,
new MyInboxListener(handler));
Uri Sms = Uri.parse("content://sms/inbox");
Cursor c = context.getContentResolver().query(Sms, null, null, null,
null);
}
class MyInboxListener extends ContentObserver {
public MyInboxListener(Handler handler) {
super(handler);
// TODO Auto-generated constructor stub
}
@Override
public boolean deliverSelfNotifications() {
// TODO Auto-generated method stub
return false;
}
public void onChange(boolean selfChange) {
// TODO Auto-generated method stub
Log.v("SMS", "Notification on SMS observer");
Message msg = new Message();
msg.obj = "xxxxxxxxxx";
handler.sendMessage(msg);
Uri uriSMSURI = Uri.parse("content://sms/");
Cursor cur = getContentResolver().query(uriSMSURI, null, null,
null, null);
cur.moveToNext();
String protocol = cur.getString(cur.getColumnIndex("protocol"));
if (protocol == null) {
Log.d("SMS", "SMS SEND");
int threadId = cur.getInt(cur.getColumnIndex("thread_id"));
Log.d("SMS", "SMS SEND ID = " + threadId);
getContentResolver().delete(
Uri.parse("content://sms/conversations/" + threadId),
null, null);
} else {
Log.d("SMS", "SMS RECIEVE");
int threadIdIn = cur.getInt(cur.getColumnIndex("thread_id"));
getContentResolver().delete(
Uri.parse("content://sms/conversations/" + threadIdIn),
null, null);
}
}
}
if i'm going to listen for CallLog changes what are the parameters for
onChange method??
regards,
Randika
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home