标签:ras des android and 接收 putextra java add logs
//注册本地广播接受者 LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity()); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("test"); BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { //接收到广播做出的操作 } }; broadcastManager.registerReceiver(mReceiver, intentFilter); //发送广播 Intent intent = new Intent("test"); Bundle bundle = new Bundle(); bundle.putInt("msgNum", sum); intent.putExtras(bundle); LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intent); @Override public void onDestroy() { super.onDestroy(); //注销广播,释放资源 broadcastManager.unregisterReceiver(mReceiver); }
标签:ras des android and 接收 putextra java add logs
原文地址:http://www.cnblogs.com/android-lw-2017/p/6596136.html