contentobserver

ContentObserver used for SMS [duplicate]

安稳与你 提交于 2019-11-29 21:32:16
问题 This question already has an answer here: Practical way to find out if SMS has been sent 3 answers I'm trying to extract the sent SMS. I know there is no BroadcastReciver for this. So I've found that I can use ContentObserver to listen changes in the db. How can I implement this? My objective is to get only the new sms sent and send it via POST on the DB Thanks 回答1: Here is a code fragment to do this. The key is to use a selection that looks only for "type = outgoing messages". Also since the

How to get URI of inserted row in my content observer?

自闭症网瘾萝莉.ら 提交于 2019-11-29 15:28:33
In my application, I am inserting values in database from a different class which gives me id of inserted row. I have registered an observer of it in my UI and whenever any row is inserted, my UI content observer will get called. Both the classes are entirely different so I am finding it difficult to get inserted row id. Is there any way to get this row id in my content observer so that I can update my UI accordingly? P.S. context.getContentResolver().notifyChange(uri, null); is not my solution, as i want effected in ( to update effected change ) on UI . When you insert the new row, you have

ContentObserver should call if and only if ContactsContract.Contacts.CONTENT_URI changes

*爱你&永不变心* 提交于 2019-11-29 06:15:27
As my application uses content from android.provider.ContactsContract.Data (API > 11) and ContactsContract.Contacts.CONTENT_URI (API < 11) to populate Contacts . I've tried to registerContentObserver() against these provider. But it calls my ContentObserver even if I tries to Call a person from device as soon as I put the call. It does trigger my ContentObserver which is not useful for me as there's no Content Change in Contacts Provider . Root Cause: Seems like LAST_TIME_CONTACTED or something in ContactsContract.Contacts.CONTENT_URI do changes when a call has been made from device which

SMS sent observer executes 3 times

丶灬走出姿态 提交于 2019-11-29 04:46:41
I have defined the following service with an observer of messages sent. The problem is that when sending a message, I sense that is called 3 times onChange method of contentobserver. ¿Someone know tell me why? Thanks public class DSMSService extends Service { private static final String CONTENT_SMS = "content://sms"; private class MyContentObserver extends ContentObserver { ContentValues values = new ContentValues(); int threadId; public MyContentObserver() { super(null); } @Override public void onChange(boolean selfChange) { super.onChange(selfChange); Log.v(TAG, "****************************

Android notify when phone book is updated(Content Observer)

旧时模样 提交于 2019-11-29 03:59:48
I want to get a notification on my phone if there is any change in the contact database(add,delete).Right now i am using ContentObserver to get notified.Following is my code.Problem is that i able not able to know which contact is changed.Can anyone help??? public class ContentObserverActivity extends Activity { Button registerbutton; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); registerbutton=(Button)findViewById(R.id.button1); registerbutton.setOnClickListener(new OnClickListener() { @Override public void

ContentObserver onChange

狂风中的少年 提交于 2019-11-29 00:07:42
The documentation of the ContentObserver is not clear to me. On which thread is the onChange of a ContentObserver called? I checked and it is not the thread where you created the observer. It looks like it is the thread that sends the notification but I didn't find a documentation about it. The Thread that the ContentObserver.onChange() method is executed on is the ContentObserver constructor 's Handler 's Looper 's Thead . For example, to have it run on the main UI thread , the code may look like this: // returns the applications main looper (which runs on the application's // main UI thread)

How to listen contact inserted/updated/deleted in address book

风格不统一 提交于 2019-11-28 21:23:19
There are lots of questions related to it but none of them help me to get the solution. I am trying to sync all contacts from device to remote server and able to do it easily but when there is a change in contact like update/delete/insert(new contact) unable to find the solution. Tried using ContentObserver but onChange() is getting called multiple times. It's difficult to find the contact changes data. public class ContactService extends Service { private int mContactCount; @Override public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { super.onCreate();

ContentObserver onChange

风格不统一 提交于 2019-11-27 21:23:54
问题 The documentation of the ContentObserver is not clear to me. On which thread is the onChange of a ContentObserver called? I checked and it is not the thread where you created the observer. It looks like it is the thread that sends the notification but I didn't find a documentation about it. 回答1: The Thread that the ContentObserver.onChange() method is executed on is the ContentObserver constructor's Handler's Looper's Thead. For example, to have it run on the main UI thread , the code may

How do I make my Android ContentObserver for ContactsContract detect a added, updated or deleted contact?

◇◆丶佛笑我妖孽 提交于 2019-11-27 19:01:23
I am able to get a generic notification "that there was a change to the contacts DB", but I want to know the specific record that was inserted, updated, or deleted. Following is the code that gets registered and gets the onChange notification. Unfortunately, it is not specific which makes my processing exhaustive and inefficient. Here is the code stub: if ((mNativeContactsObserver == null) && (mHandler == null)) { mHandler = new Handler(this.getMainLooper()) { }; mNativeContactsObserver = new ContentObserver(mHandler) { @Override public void onChange(boolean selfChange) { super.onChange

Block outgoing SMS by contentObserver

强颜欢笑 提交于 2019-11-27 16:47:44
问题 I want to block SMS by contentObserver . For that I want to get the phone number of the SMS first. What do I do to get the number? This is the code that I have, just counting the number of SMS. package com.SMSObserver4; import android.app.Activity; import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.provider.Contacts; import android.provider.Contacts.People.Phones; public class