我正在註冊許多IntentFilter
到一個BroadcastReceiver
並取消註冊所有IntentFilter
當這些不是必需的,如下面的代碼。取消註冊來自BroadcastReceiver的單一IntentFilter在android中
事情在這一點上運作良好。但現在我需要註銷一個IntentFilter
而不是全部。
這是如何實現的,或者是解決方法還是更好的方法?
private void registerBroadcastReceiver() {
Log.i(TAG, LogHelper.at() + "Begin");
LocalBroadcastManager
.getInstance(getActivity())
.registerReceiver(broadcastReceiver,
new IntentFilter(getString(R.string.onInitiateCustomerVerificationSUCCESS)));
LocalBroadcastManager
.getInstance(getActivity())
.registerReceiver(broadcastReceiver,
new IntentFilter(getString(R.string.onInitiateCustomerVerificationFAILURE)));
Log.i(TAG, LogHelper.at() + "End");
}
private void unRegisterBroadcastReceiver() {
Log.i(TAG, LogHelper.at() + "Begin");
LocalBroadcastManager
.getInstance(OkeKeyApplication.getAppContext())
.unregisterReceiver(broadcastReceiver);
Log.i(TAG, LogHelper.at() + "End");
}