List of usage examples for android.support.v4.content LocalBroadcastManager getInstance
public static LocalBroadcastManager getInstance(Context context)
From source file:com.aimfire.main.MainActivity.java
/** * Override Activity lifecycle method.//from w w w . j ava 2s . c om */ @Override protected void onResume() { /* * we disable the wifi on/off feature as it is quite confusing. we show only a * toast to warn user. */ WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE); if (!manager.isWifiEnabled()) { Toast.makeText(this, R.string.error_wifi_off, Toast.LENGTH_LONG).show(); } /* * register for intents sent by the cloud backend service */ LocalBroadcastManager.getInstance(this).registerReceiver(mAimfireServiceMsgReceiver, new IntentFilter(MainConsts.AIMFIRE_SERVICE_MESSAGE)); /* * navigate the selected tab */ getSupportActionBar().setSelectedNavigationItem(mTabPosition); super.onResume(); }
From source file:com.android.messaging.ui.UIIntentsImpl.java
@Override public void broadcastConversationSelfIdChange(final Context context, final String conversationId, final String conversationSelfId) { final Intent intent = new Intent(CONVERSATION_SELF_ID_CHANGE_BROADCAST_ACTION); intent.putExtra(UI_INTENT_EXTRA_CONVERSATION_ID, conversationId); intent.putExtra(UI_INTENT_EXTRA_CONVERSATION_SELF_ID, conversationSelfId); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); }
From source file:biz.wiz.android.wallet.WalletApplication.java
public void replaceWallet(final Wallet newWallet) { internalResetBlockchain(); // implicitly stops blockchain service wallet.shutdownAutosaveAndWait();//from www .j a v a 2s.c o m wallet = newWallet; config.maybeIncrementBestChainHeightEver(newWallet.getLastBlockSeenHeight()); afterLoadWallet(); final Intent broadcast = new Intent(ACTION_WALLET_CHANGED); broadcast.setPackage(getPackageName()); LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast); }
From source file:ca.rmen.android.scrumchatter.main.MainActivity.java
/** * Share a file using an intent chooser. * * @param fileExport The object responsible for creating the file to share. *//*from www . j av a2s . c o m*/ private void shareFile(final FileExport fileExport) { DialogFragmentFactory.showProgressDialog(MainActivity.this, getString(R.string.progress_dialog_message), PROGRESS_DIALOG_FRAGMENT_TAG); Schedulers.io().scheduleDirect(() -> { boolean result = fileExport.export(); Intent intent = new Intent(ACTION_EXPORT_COMPLETE); intent.putExtra(EXTRA_EXPORT_RESULT, result); LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent); Log.v(TAG, "broadcast " + intent); }); }
From source file:com.allthatseries.RNAudioPlayer.Playback.java
/** * Makes sure the media player exists and has been reset. This will create * the media player if needed, or reset the existing media player if one * already exists.//from w w w . j a va 2 s . c o m */ private void createMediaPlayerIfNeeded() { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); // Make sure the media player will acquire a wake-lock while // playing. If we don't do that, the CPU might go to sleep while the // song is playing, causing playback to stop. mMediaPlayer.setWakeMode(mContext.getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); // we want the media player to notify us when it's ready preparing, // and when it's done playing: mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnErrorListener(this); mMediaPlayer.setOnSeekCompleteListener(this); new Thread(new Runnable() { @Override public void run() { while (mMediaPlayer != null) { try { Thread.sleep(500); mHandler.post(new Runnable() { @Override public void run() { if (mMediaPlayer != null && mMediaPlayer.isPlaying()) { Intent intent = new Intent("update-position-event"); intent.putExtra("currentPosition", mMediaPlayer.getCurrentPosition()); LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent); } } }); } catch (Exception e) { e.printStackTrace(); } } } }).start(); } else { mMediaPlayer.reset(); } }
From source file:com.aimfire.main.MainActivity.java
/** * Override Activity lifecycle method.// www . j a v a2s . c o m */ @Override protected void onPause() { /* * unregister for intents sent by the cloud backend service */ LocalBroadcastManager.getInstance(this).unregisterReceiver(mAimfireServiceMsgReceiver); super.onPause(); }
From source file:com.aimfire.gallery.GalleryActivity.java
/** * Override Activity lifecycle method.//from w w w . ja v a 2 s .co m */ @Override protected void onResume() { super.onResume(); if (mDisplayMode == DisplayMode.Cardboard) { /* * reload display preferences (that's different from Cardboard) */ loadDisplayPrefs(); invalidateOptionsMenu(); switchDisplayMode(); } // /* // * upon resuming, the page that was being displayed may have // * been deleted, so need to update the view pager // */ // updateViewPager(null, mViewPager.getCurrentItem(), -1); /* * register for intents sent by the media processor service */ LocalBroadcastManager.getInstance(this).registerReceiver(mPhotoProcessorMsgReceiver, new IntentFilter(MainConsts.PHOTO_PROCESSOR_MESSAGE)); LocalBroadcastManager.getInstance(this).registerReceiver(mMovieProcessorMsgReceiver, new IntentFilter(MainConsts.MOVIE_PROCESSOR_MESSAGE)); /* * register for intents sent by the download completion service */ LocalBroadcastManager.getInstance(this).registerReceiver(mDownloadMsgReceiver, new IntentFilter(MainConsts.FILE_DOWNLOADER_MESSAGE)); }
From source file:com.android.managedprovisioning.ProfileOwnerProvisioningService.java
private void notifyActivityOfSuccess() { Intent successIntent = new Intent(ACTION_PROVISIONING_SUCCESS); LocalBroadcastManager.getInstance(ProfileOwnerProvisioningService.this).sendBroadcast(successIntent); }
From source file:com.alibaba.weex.commons.AbsWeexActivity.java
public void registerBroadcastReceiver(BroadcastReceiver receiver, IntentFilter filter) { mBroadcastReceiver = receiver != null ? receiver : new DefaultBroadcastReceiver(); if (filter == null) { filter = new IntentFilter(); }// w w w . j a va2s .c o m filter.addAction(IWXDebugProxy.ACTION_DEBUG_INSTANCE_REFRESH); filter.addAction(WXSDKEngine.JS_FRAMEWORK_RELOAD); LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(mBroadcastReceiver, filter); if (mReloadListener == null) { setReloadListener(new WxReloadListener() { @Override public void onReload() { createWeexInstance(); renderPage(); } }); } if (mRefreshListener == null) { setRefreshListener(new WxRefreshListener() { @Override public void onRefresh() { createWeexInstance(); renderPage(); } }); } }
From source file:co.carlosjimenez.android.currencyalerts.app.sync.ForexSyncAdapter.java
/** * Send sync broadcast so App and Widget can update the rate values immediately. * * @param status Status of the rate sync */// w w w. j a va 2 s. com private void sendSyncBroadcast(int status) { Context context = getContext(); // Setting the package ensures that only components in our app will receive the broadcast Intent dataUpdatedIntent = new Intent(ACTION_DATA_UPDATED).setPackage(context.getPackageName()) .putExtra(FOREX_DATA_STATUS, status); LocalBroadcastManager.getInstance(context).sendBroadcast(dataUpdatedIntent); }