Monday, May 13, 2013

[android help] Cannot Disable Broadcast Receiver


I got the logic for disable/enable broadcast receiver from here.



@Override
public void onCheckedChanged(CompoundButton v, boolean checked) {
// TODO Auto-generated method stub

if (v == disableBlock) {
manageBlockSetting(checked);
}
}

private void manageBlockSetting(boolean disable) {
Log.e(tag, "Disable : " + disable);
int flag = disable ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
: PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
ComponentName component = new ComponentName(SettingActivity.this, PhoneCallReceiver.class);

getApplication().getPackageManager().setComponentEnabledSetting(component, flag, PackageManager.DONT_KILL_APP);
editSharedPreferences(StoreConstantValue.SETTING_DISABLE_BLOCK, disable);
}


And in Manifest.xml



android:enabled="true" >






When I deploy with android:enabled="false"


I can enable it once. But when I want to disable. Nothing happens, I can't disable it. It is still block incoming calls.


My device is Samsung Galaxy S2 with Android 2.3.3


Any help? Thanks



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...