contentobserver

ContentObserver vs. BroadCastReceiver : Battery Usage, Ram, CPU?

a 夏天 提交于 2019-12-05 11:57:48
Since there is such a needed concern for an application's battery usage, ram and cpu usage, what is the expense of multiple contentobservers vs. multiple broadcastreceivers? Example 1: A service running with START_STICKY using 5 contentobservers registered/unregistered properly. Example 2: A service being fired from 5 broadcastreceivers set in the manifest. Example 3: A service running with START_STICKY using 5 registered broadcastreceivers. What is the true difference in battery usage/ram/cpu between an observer and a receiver? Can any pros chime in on this? I'm assuming 1 instance wouldn't

Last sent SMS/text message: how to retrieve via ContentObserver?

余生长醉 提交于 2019-12-05 07:02:38
问题 I know that there are some questions around and I've been through them all, I guess. My carrier is kind enough to offer 50 free SMS each month. Now I would like to make myself a little counter that runs in the background and notifies me whenever I reach that limit. (Yes, I am aware that there will already be apps for this). Therefore, I would like a service to be notified whenever an SMS/test msg is sent . So the way to go would be a ContentObserver . I set one up (2) and register it like

get SMS number at outgoing time by contentObserver

十年热恋 提交于 2019-12-04 14:09:16
this is the code that i have try to get sms number when i send sms from default emulator, but it not work. just check out and tell me about that Thanx package com.SMSOberver5; 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.widget.Toast; public class SMSOberver5 extends Activity { /** Called when the activity is first created. */ Handler handler = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

How to register ContentObserver for media volume change?

邮差的信 提交于 2019-12-04 14:08:10
I encountered a problem when I wanted to implement volume change detection. As the change detection has to be detected in the background via Service, I can not intercept volume key presses. I've tried ContentObserver to listen for volume settings change, but it didn't worked. But I've dig a bit more, and found that my ContentObserver detects volume change when I register it like this: this.getApplicationContext().getContentResolver().registerContentObserver( android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserver ); I've tried to change the first parameter - the URI of

How to detect new apps in an Android device

老子叫甜甜 提交于 2019-12-04 14:02:51
问题 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? 回答1: You can register a BroadcastReceiver using Intent.ACTION_PACKAGE_ADDED (and also Intent

Sqlite Database updates triggers Service to update via Content Observer

被刻印的时光 ゝ 提交于 2019-12-04 14:01:38
问题 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()

Contacts ContentObserver called randomly

随声附和 提交于 2019-12-04 10:59:38
i am using a ContentObserver to listen for changes in the contacts database. now i realized that the onChange() method gets randomly called, even if i have not made any changes to the contacts. i suspect this is somehow related to the automatic contact syncing (even though there are no real changes to the contacts at this point). is there a possibility to get notified only if there are real changes in the contacts, made by the user? thx simon public class ContactsObserver extends ContentObserver { private final static String TAG = ContactsObserver.class.getSimpleName(); private Context ctx;

ContentObserver for listening contact changes

好久不见. 提交于 2019-12-04 10:40:41
问题 I really don't understand why content observer listens the changes which is not related with the contact info. I simply registered to the URI which I wanna listen the changes: getContentResolver().registerContentObserver(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, true, contactsObserver); But after calling someone or texting to someone, it triggers and calls onChange method in ContentObserver. So I need to re-sync all the contact list with my application although I don't need to do.

Android: Detect SMS Outgoing, Incorrect Count

血红的双手。 提交于 2019-12-04 01:09:13
问题 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{

Last sent SMS/text message: how to retrieve via ContentObserver?

痞子三分冷 提交于 2019-12-03 21:25:49
I know that there are some questions around and I've been through them all, I guess. My carrier is kind enough to offer 50 free SMS each month. Now I would like to make myself a little counter that runs in the background and notifies me whenever I reach that limit. (Yes, I am aware that there will already be apps for this). Therefore, I would like a service to be notified whenever an SMS/test msg is sent . So the way to go would be a ContentObserver . I set one up (2) and register it like that (1): (1) Uri URI = Uri.parse("content://sms/sent"); String[] columns = {"_id", "date"}; Cursor c =