contentobserver

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

≯℡__Kan透↙ 提交于 2019-12-03 18:02:04
问题 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

How to detect new apps in an Android device

送分小仙女□ 提交于 2019-12-03 08:51:35
I want to detect when the user installs or deletes an app, and I didn't find a BroadcastReceiver that does this. In my app, I get the information about the installed apps with the class PackageManager , but I don't want to scan the apps periodically. Is there any BroadcastReceiver that does this? Or any ContentObserver ? Is it possible to get a notification that an app has been installed or removed? You can register a BroadcastReceiver using Intent.ACTION_PACKAGE_ADDED (and also Intent.ACTION_PACKAGE_REMOVED and/or Intent.ACTION_PACKAGE_CHANGED if necessary). For instance, void

Sqlite Database updates triggers Service to update via Content Observer

痴心易碎 提交于 2019-12-03 08:08:24
I'm trying to use a Content Observer to update a Service when any changes happen to the sqlite database in my app. I'm confused as to what to do, so I put together some code below. Usually, Content Observers are used with contacts or mediaplayer with a background service. In my research I read that it can be used with the sqlite database on the phone. Questions: 1. Since Sqlite database does not have a uri, what info do I replace People.CONTENT_URI in this.getContentResolver().registerContentObserver (People.CONTENT_URI, true, contentObserver); 2. In my research I didn't find any code that

Difference between ContentObserver and DatasetObserver?

霸气de小男生 提交于 2019-12-03 01:41:14
问题 What is difference between ContentObserver and DatasetObserver ? When one or another should be used? I get Cursor with single row. I want to be notified about data changes - eg. when row is updated. Which observer class should I register? 回答1: If you are using a ContentProvider (via ContentResolver or Activity.managedQuery() ) to get your data, simply attach a ContentObserver to your Cursor . The code in onChange() will be called whenever the ContentResolver broadcasts a notification for the

Difference between ContentObserver and DatasetObserver?

China☆狼群 提交于 2019-12-02 15:11:06
What is difference between ContentObserver and DatasetObserver ? When one or another should be used? I get Cursor with single row. I want to be notified about data changes - eg. when row is updated. Which observer class should I register? If you are using a ContentProvider (via ContentResolver or Activity.managedQuery() ) to get your data, simply attach a ContentObserver to your Cursor . The code in onChange() will be called whenever the ContentResolver broadcasts a notification for the Uri associated with your cursor. Cursor myCursor = managedQuery(myUri, projection, where, whereArgs, sortBy)

Android : Catching Outgoing SMS using ContentObserver or receiver not working

时光怂恿深爱的人放手 提交于 2019-12-01 09:18:53
i trying to catch outgoing SMS event using content observer. //TEST OBSERVER ContentObserver co = new SMSoutObserver(new Handler(), getApplicationContext()); ContentResolver contentResolver = getApplicationContext().getContentResolver(); contentResolver.registerContentObserver(Uri.parse("content://sms/out"),true, co); // END TEST OBSERVER and public class SMSoutObserver extends ContentObserver { private Context mCtx; public SMSoutObserver(Handler handler, Context ctx) { super(handler); mCtx = ctx; } @Override public void onChange(boolean selfChange) { super.onChange(selfChange); // save the

Android : Catching Outgoing SMS using ContentObserver or receiver not working

人走茶凉 提交于 2019-12-01 06:20:39
问题 i trying to catch outgoing SMS event using content observer. //TEST OBSERVER ContentObserver co = new SMSoutObserver(new Handler(), getApplicationContext()); ContentResolver contentResolver = getApplicationContext().getContentResolver(); contentResolver.registerContentObserver(Uri.parse("content://sms/out"),true, co); // END TEST OBSERVER and public class SMSoutObserver extends ContentObserver { private Context mCtx; public SMSoutObserver(Handler handler, Context ctx) { super(handler); mCtx =

Android: Detect SMS Outgoing, Incorrect Count

孤者浪人 提交于 2019-12-01 04:00:41
I am trying to make an application to count the number of outgoing SMS messages from a phone. Presently I have the following code: private void listenForSMS(){ Log.v("SMSTEST", "STARTED LISTENING FOR SMS OUTGOING"); Handler handle = new Handler(){}; SMSObserver myObserver = new SMSObserver(handle); ContentResolver contentResolver = getContentResolver(); contentResolver.registerContentObserver(Uri.parse("content://sms"),true, myObserver); } private class SMSObserver extends ContentObserver{ int count = 0; String lastMessage = null; public SMSObserver(Handler handler) { super(handler); } public

FIleObserver and ContentObserver not working in Android Marshmallow

眉间皱痕 提交于 2019-12-01 03:57:20
I have issue with both FIleObserver and ContentObserver not working in Android Marshmallow. I am using this thing for detecting changes that happening inside a folder. I set run time permissions for marshmallow. But after that also it shows no events. It works perfectly in other versions. Please help me to solve this problem. First I tried Content Resolver inside Service for detect folder changes in background. public class TestService extends Service { @Override public void onCreate() { super.onCreate(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { initial();

ContentObserver used for SMS [duplicate]

落花浮王杯 提交于 2019-11-30 15:19:30
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 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 content DB can get triggered by any change, keep track (somehow) of what has already been processed. int