List of usage examples for android.support.v4.content LocalBroadcastManager getInstance
public static LocalBroadcastManager getInstance(Context context)
From source file:com.anykey.balala.activity.MainActivity.java
@Override protected void onResume() { super.onResume(); receiver = new LocalRouterReceiver(new LocalRouterReceiver.RouterCallback() { @Override/*ww w . j a v a 2 s. co m*/ public void onHandle(byte[] parcel, Object obj) { int type = new WillProtocol().getType(parcel); byte[] msgByte = new WillProtocol().getData(parcel); String msgStr = new String(msgByte).trim(); if (type == WillOutProtocol.BROADCAST_TYPE_VALUE) {//?? SystemNotificationModel.SystemBroadcast commonData = JsonUtil.fromJson(msgStr, SystemNotificationModel.SystemBroadcast.class); if (commonData.code == 4) {//?? String str = commonData.msg; int VersionCode = Integer.valueOf(str.split("%-%")[0]); String message = String.valueOf(str.split("%-%")[1]); int force = commonData.data.force; String AppURL = commonData.data.url; if (Integer.valueOf(versionCode) < VersionCode) { UploadApp uploadApp = new UploadApp( FileUtil.getSDCardDir(MainActivity.this, AppBalala.FILEPATH_UPAPK)); uploadApp.showUpApk(MainActivity.this, message, AppURL, force); if (force == 1) { sp.saveUpLoadApk(true, String.valueOf(VersionCode), message, AppURL); } } } } } }); IntentFilter filter = new IntentFilter(); filter.addAction(RouterProcess.ACTION_ROUTER_PARCEL); LocalBroadcastManager.getInstance(MainActivity.this).registerReceiver(receiver, filter); if (!sp.getApkInfo_version().equals("")) { int ApkVersion = Integer.valueOf(sp.getApkInfo_version()); if (ApkVersion > Integer.valueOf(versionCode)) {//? UploadApp uploadApp = new UploadApp( FileUtil.getSDCardDir(MainActivity.this, AppBalala.FILEPATH_UPAPK)); uploadApp.showUpApk(MainActivity.this, sp.getApkInfo_message(), sp.getApkInfo_Url(), 1); } } }
From source file:com.android.managedprovisioning.DeviceOwnerProvisioningService.java
private void sendProgressUpdateToActivity() { Intent intent = new Intent(ACTION_PROGRESS_UPDATE); intent.putExtra(EXTRA_PROGRESS_MESSAGE_ID_KEY, mLastProgressMessage); intent.setClass(this, DeviceOwnerProvisioningActivity.ServiceMessageReceiver.class); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); }
From source file:activeng.pt.activenglab.BluetoothChatService.java
/** * Indicate that the connection was lost and notify the UI Activity. */// w ww .j a v a 2 s .c o m private void connectionLost() { /* // Send a failure message back to the Activity Message msg = mHandler.obtainMessage(Constants.MESSAGE_TOAST); Bundle bundle = new Bundle(); bundle.putString(Constants.TOAST, "Device connection was lost"); msg.setData(bundle); mHandler.sendMessage(msg); */ Intent intent = new Intent(Constants.MESSAGE_BT_FAIL).putExtra(Intent.EXTRA_TEXT, "Device connection was lost"); //mContext.sendBroadcast(intent); LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent); // Start the service over to restart listening mode BluetoothChatService.this.start(); }
From source file:com.antew.redditinpictures.library.service.RESTService.java
public void onRequestComplete(Intent result) { LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(result); }
From source file:bucci.dev.freestyle.TimerActivity.java
@Override protected void onResume() { if (DEBUG)/*from ww w. ja va 2 s. c o m*/ Log.d(TAG, "onResume()"); LocalBroadcastManager.getInstance(this).registerReceiver(mMsgReceiver, new TimerIntentFilter()); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(NotificationCreator.NOTIFICATION_TIMER_RUNNING); super.onResume(); }
From source file:com.anjalimacwan.fragment.NoteEditFragment.java
@Override public void onStart() { super.onStart(); if (!listener.isShareIntent()) LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, filter); }
From source file:br.liveo.ndrawer.ui.activity.MainActivity.java
License:asdf
@Override public void onPause() { super.onPause(); /* unregisterReceiver(mReceiver); unregisterReceiver(mGattUpdateReceiver);*/ LocalBroadcastManager.getInstance(this).unregisterReceiver(mRegistrationBroadcastReceiver); if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) { scanLeDevice(false);/*from w w w . j av a2 s . co m*/ } }
From source file:cn.wyl.superwechat.ui.MainActivity.java
private void registerBroadcastReceiver() { broadcastManager = LocalBroadcastManager.getInstance(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constant.ACTION_CONTACT_CHANAGED); intentFilter.addAction(Constant.ACTION_GROUP_CHANAGED); intentFilter.addAction(RedPacketConstant.REFRESH_GROUP_RED_PACKET_ACTION); broadcastReceiver = new BroadcastReceiver() { @Override/*from ww w. jav a 2s . c om*/ public void onReceive(Context context, Intent intent) { updateUnreadLabel(); updateUnreadAddressLable(); // if (currentTabIndex == 0) { // refresh conversation list if (conversationListFragment != null) { conversationListFragment.refresh(); } //} else if (currentTabIndex == 1) { if (contactListFragment != null) { contactListFragment.refresh(); } // } String action = intent.getAction(); if (action.equals(Constant.ACTION_GROUP_CHANAGED)) { if (EaseCommonUtils.getTopActivity(MainActivity.this).equals(GroupsActivity.class.getName())) { GroupsActivity.instance.onResume(); } } //red packet code : ??? if (action.equals(RedPacketConstant.REFRESH_GROUP_RED_PACKET_ACTION)) { if (conversationListFragment != null) { conversationListFragment.refresh(); } } //end of red packet code } }; broadcastManager.registerReceiver(broadcastReceiver, intentFilter); }
From source file:com.anjalimacwan.fragment.NoteEditFragment.java
@Override public void onStop() { super.onStop(); if (!listener.isShareIntent()) LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(receiver); }
From source file:bucci.dev.freestyle.TimerActivity.java
@Override protected void onPause() { if (DEBUG)//from w w w. j a v a2 s .c o m Log.d(TAG, "onPause()"); LocalBroadcastManager.getInstance(this).unregisterReceiver(mMsgReceiver); super.onPause(); }