importandroid.database.ContentObserver;
getContentResolver().registerContentObserver(Settings.Global.getUriFor(DOZE_WHATSAPP_MODE),false,
mWhatsAppModeObserver);
getContentResolver().unregisterContentObserver(mWhatsAppModeObserver);
private ContentObserver mWhatsAppModeObserver = new ContentObserver(
new Handler()) {
public void onChange(boolean selfChange, Uri uri) {
Log.d(TAG, "mWhatsAppModeObserver:" + uri.toString());
if (uri.toString().equals(mWhatsappUri)) {
Log.d(TAG, "mWhatsAppModeObserver onChange begin ----->");
boolean isWhatsapp = mPresenter.isWhatsAppMode();
Log.d(TAG, "mWhatsAppModeObserver isWhatsapp:" + isWhatsapp);
mWhatsAppSwitch.setChecked(isWhatsapp);
mTvWhatsAppSwitchTip.setText(isWhatsapp ? R.string.feature_on : R.string.feature_off);
Log.d(TAG, "mWhatsAppModeObserver onChange end----->");
}
}
};
网友评论