List of usage examples for android.support.v4.content LocalBroadcastManager sendBroadcast
public boolean sendBroadcast(Intent intent)
From source file:com.apps.lore_f.guardianocontroller.MessagingService.java
@Override public void onMessageReceived(RemoteMessage remoteMessage) { Map<String, String> messageData; String messageTitle;/*from w w w .j ava 2s . c o m*/ String messageCommand = ""; String messageSender; // Check if message contains a data payload. if (remoteMessage.getData().size() > 0) { /* recupera i dati contenuti nel corpo del messaggio * */ messageData = remoteMessage.getData(); messageTitle = messageData.get("title"); messageCommand = messageData.get("message"); messageSender = messageData.get("reply-to"); Log.d(TAG, "received message: " + messageData); switch (messageCommand) { case "RESPONSE_FROM_SERVER:::YES_I_AM_ALIVE": // inizializzo il BroadcastManager LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this); Intent intent = new Intent("GUARDIANOCONTROLLER___HEARTBEAT_RECEIVED").putExtra("_sender-token", messageSender); broadcastManager.sendBroadcast(intent); break; } } // Also if you intend on generating your own notifications as a result of a received FCM // message, here is where that should be initiated. See sendNotification method below. }
From source file:com.github.tdudziak.gps_lock_lock.LockService.java
private void broadcastUiUpdateMessage(boolean last_message) { long remaining = getRemainingTime(); long last_fix = (System.currentTimeMillis() - mLastFixTime) / (1000 * 60); if (mLastFixTime == 0) last_fix = -1; // special value meaning "never" if (remaining <= 0 || last_message) remaining = 0; // special value meaning "no time left" Intent intent = new Intent(ACTION_UI_UPDATE); intent.putExtra(EXTRA_TIME_LEFT, (int) remaining); intent.putExtra(EXTRA_LAST_FIX, (int) last_fix); Log.v(TAG, String.format("broadcastUiUpdateMessage(); EXTRA_TIME_LEFT=%d; EXTRA_LAST_FIX=%d", remaining, last_fix));/*from w ww . j a v a 2 s. c om*/ LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(LockService.this); lbm.sendBroadcast(intent); }
From source file:com.achep.acdisplay.acdisplay.AcDisplayActivity.java
@Override public void onTimeoutEvent(Timeout timeout, int event) { switch (event) { case Timeout.EVENT_TIMEOUT: final boolean lockedSuccessful = lock(); if (lockedSuccessful) { LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this); manager.sendBroadcast(new Intent(App.ACTION_INTERNAL_TIMEOUT)); // TODO: Detect if user has really missed this wake-up or no. manager.sendBroadcast(new Intent(App.ACTION_INTERNAL_PING_SENSORS)); }//from ww w .j av a 2 s . c o m break; } }
From source file:nl.thehyve.transmartclient.oauth.TokenGetterTask.java
protected void onPostExecute(ServerResult serverResult) { super.onPostExecute(serverResult); Log.d(TAG, "Sending broadcast for serverResult with userefreshtoken = " + userefreshtoken); LocalBroadcastManager mBroadcastMgr = LocalBroadcastManager.getInstance(this.mContext); Intent i = new Intent(TOKEN_RECEIVED_INTENT); i.putExtra("serverResult", serverResult); i.putExtra("userefreshtoken", userefreshtoken); // TODO pass along transmartServer or unique identifier for it mBroadcastMgr.sendBroadcast(i); }
From source file:net.zhdev.ctrlvkeyboard.FireReceiver.java
@Override public void onReceive(Context context, Intent intent) { LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); Intent realFireIntent = new Intent(Constants.ACTION_PASTE_TEXT_TASKER); realFireIntent.putExtras(intent.getExtras()); boolean isSynchronous = isOrderedBroadcast(); realFireIntent.putExtra(Constants.EXTRA_IS_SYNCHRONOUS, isSynchronous); boolean broadcastSent = lbm.sendBroadcast(realFireIntent); if (isSynchronous) { if (broadcastSent) { setResultCode(TaskerPlugin.Setting.RESULT_CODE_PENDING); } else {// w w w. j av a 2 s.co m setResultCode(TaskerPlugin.Setting.RESULT_CODE_FAILED); } } }
From source file:ca.farrelltonsolar.classic.ChargeControllers.java
private void BroadcastRemoveNotification() { LocalBroadcastManager broadcaster = LocalBroadcastManager.getInstance(context); Intent pkg = new Intent(Constants.CA_FARRELLTONSOLAR_CLASSIC_REMOVE_CHARGE_CONTROLLER); broadcaster.sendBroadcast(pkg); }
From source file:ca.farrelltonsolar.classic.ChargeControllers.java
private void BroadcastUpdateNotification() { LocalBroadcastManager broadcaster = LocalBroadcastManager.getInstance(context); Intent pkg = new Intent(Constants.CA_FARRELLTONSOLAR_CLASSIC_UPDATE_CHARGE_CONTROLLERS); broadcaster.sendBroadcast(pkg); }
From source file:io.barracks.ota.client.PackageDownloadService.java
/** * Convenience method for notifying the application of a download completion using the {@link LocalBroadcastManager} * * @param details The {@link UpdateDetails} retrieved from the Barracks platform. * @param destination The destination where the file has been moved. * @param callback The callback identifier. *///from www . j a va2s . c om private void notifySuccess(UpdateDetails details, File destination, int callback) { LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this); manager.sendBroadcast(new Intent(ACTION_DOWNLOAD_PACKAGE).addCategory(DOWNLOAD_SUCCESS) .putExtra(EXTRA_UPDATE_DETAILS, details).putExtra(EXTRA_CALLBACK, callback) .putExtra(EXTRA_FINAL_DEST, destination.getPath())); }
From source file:io.barracks.ota.client.PackageDownloadService.java
/** * Convenience method for notifying the application of a download failure using the {@link LocalBroadcastManager} * * @param details The {@link UpdateDetails} retrieved from the Barracks platform. * @param exception The exception caught during the process. * @param callback The callback identifier. *///from w w w . j a v a 2 s. com private void notifyError(UpdateDetails details, Exception exception, int callback) { LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this); manager.sendBroadcast(new Intent(ACTION_DOWNLOAD_PACKAGE).addCategory(DOWNLOAD_ERROR) .putExtra(EXTRA_UPDATE_DETAILS, details).putExtra(EXTRA_CALLBACK, callback) .putExtra(EXTRA_EXCEPTION, exception)); }
From source file:io.barracks.ota.client.PackageDownloadService.java
/** * Convenience method for notifying the application of a download progress using the {@link LocalBroadcastManager} * * @param details The {@link UpdateDetails} retrieved from the Barracks platform. * @param progress The progress percentage. * @param callback The callback identifier. *//*from w w w. j a v a 2s . c o m*/ private void notifyProgress(UpdateDetails details, int progress, int callback) { LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this); manager.sendBroadcast(new Intent(ACTION_DOWNLOAD_PACKAGE).addCategory(DOWNLOAD_PROGRESS) .putExtra(EXTRA_UPDATE_DETAILS, details).putExtra(EXTRA_CALLBACK, callback) .putExtra(EXTRA_PROGRESS, progress)); }