Example usage for android.content Context sendBroadcast

List of usage examples for android.content Context sendBroadcast

Introduction

In this page you can find the example usage for android.content Context sendBroadcast.

Prototype

public abstract void sendBroadcast(@RequiresPermission Intent intent);

Source Link

Document

Broadcast the given intent to all interested BroadcastReceivers.

Usage

From source file:Main.java

public static void addImageToDeviceGallery(final Context context, final String imagePath) {
    final Intent mediaScanIntent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
    final File f = new File(imagePath);
    final Uri contentUri = Uri.fromFile(f);
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
}

From source file:Main.java

/**
 * Notifies UI to display a message.//from  w  ww .  j a va 2s  .c  om
 * <p>
 * This method is defined in the common helper because it's used both by the
 * UI and the background service.
 * 
 * @param context
 *            application's context.
 * @param message
 *            message to be displayed.
 */
public static void displayMessage(Context context, String message) {
    Log.i("CommonUtilities", "================Inside DisplayMessege Method==============================");
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}

From source file:foodcenter.android.AndroidUtils.java

public static void notifySignOut(Context context, String msg) {
    MsgBroadcastReceiver.progressDismissAndToastMsg(context, msg);

    Intent intent = new Intent(ACTION_SIGNED_OUT);
    intent.putExtra(EXTRA_SIGN_MESSAGE, msg);
    context.sendBroadcast(intent);
}

From source file:ufms.br.com.ufmsapp.gcm.UfmsGcmListenerService.java

static void updateNotasLista(Context context) {
    Intent intent = new Intent(Constants.UPDATE_NOTA_INTENT);
    context.sendBroadcast(intent);
}

From source file:ufms.br.com.ufmsapp.gcm.UfmsGcmListenerService.java

static void updateEventosList(Context context) {
    Intent intent = new Intent(Constants.UPDATE_EVENTO_INTENT);
    context.sendBroadcast(intent);
}

From source file:ufms.br.com.ufmsapp.gcm.UfmsGcmListenerService.java

static void updateDisciplinasList(Context context) {
    Intent intent = new Intent(Constants.UPDATE_DISCIPLINA_INTENT);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void sendBroadcast(Context context, String filter, String bundleName, Bundle bundle) {
    if (context == null) {
        return;/*from   w  ww  . jav a 2  s.  co m*/
    }
    Intent intent = new Intent();
    intent.setAction(filter);
    intent.putExtra(bundleName, bundle);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void sendBroadcast(Context context, String filter, String name, String value, String name1,
        String value1) {/* ww  w.  j  a  v a  2  s. co  m*/
    Intent intent = new Intent();
    intent.putExtra(name, value);
    intent.putExtra(name1, value1);
    intent.setAction(filter);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void broadcast(Context context, String what, Map<String, String> params) {
    Intent intent = new Intent(what);
    if (params != null) {
        Set<String> keys = params.keySet();
        for (String string : keys) {
            intent.putExtra(string, params.get(string));
        }//from   w w w  . j  a  va  2 s  .  co  m
    }
    context.sendBroadcast(intent);
}

From source file:Main.java

/**
 * Notifies UI to display a message./*from w  w w .j  a  v a2 s . c om*/
 * <p>
 * This method is defined in the common helper because it's used both by
 * the UI and the background service.
 *
 * @param context application's context.
 * @param message message to be displayed.
 * @param loc location that road side sensor has.
 */
static void displayMessage(Context context, String message, Location loc) {
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_MESSAGE, message);
    intent.putExtra(LATITUDE, loc.getLatitude());
    intent.putExtra(LONGITUDE, loc.getLongitude());
    context.sendBroadcast(intent);

}