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 broadcast(Context context, String action, Map<String, String> params) {
    Intent intent = new Intent(action);
    if (params != null) {
        Set<String> keys = params.keySet();
        for (String string : keys) {
            intent.putExtra(string, params.get(string));
        }/* www .  ja va  2  s  . com*/
    }
    context.sendBroadcast(intent);
}

From source file:com.android.mms.widget.MmsWidgetProvider.java

public static void notifyDatasetChanged(Context context) {
    if (Log.isLoggable(LogTag.WIDGET, Log.VERBOSE)) {
        Log.v(TAG, "notifyDatasetChanged");
    }//from   ww w . j  a va 2 s  . c om
    final Intent intent = new Intent(ACTION_NOTIFY_DATASET_CHANGED);
    context.sendBroadcast(intent);
}

From source file:se.erichansander.retrotimer.RetroTimer.java

/**
 * Try to return the app to its initial state
 *///  w ww . j  a v  a  2  s  .c o  m
public static void handleFatalError(Context context) {
    Intent intent = new Intent(RetroTimer.ALARM_DISMISS_ACTION);
    context.sendBroadcast(intent);

    cancelAlarm(context);
}

From source file:Main.java

public static void setBadgeOfMadMode(Context context, int count, String packageName, String className) {
    Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
    intent.putExtra("badge_count", count);
    intent.putExtra("badge_count_package_name", packageName);
    intent.putExtra("badge_count_class_name", className);
    context.sendBroadcast(intent);
}

From source file:ua.setcom.developertools.Onscreen.DevToolsService.java

public static void showNotification(Context context) {
    final Intent intent = new Intent(SHOW_NOTIFICATION_ACTION);
    intent.setClass(context, getIntentListenerClass());
    context.sendBroadcast(intent);
}

From source file:com.concentriclivers.mms.com.android.mms.widget.MmsWidgetProvider.java

public static void notifyDatasetChanged(Context context) {
    //        if (Log.isLoggable(LogTag.WIDGET, Log.VERBOSE)) {
    Log.v(TAG, "notifyDatasetChanged");
    //        }/*from  w w  w .j av a  2  s  .  com*/
    final Intent intent = new Intent(ACTION_NOTIFY_DATASET_CHANGED);
    context.sendBroadcast(intent);
}

From source file:de.ub0r.android.portaltimer.UpdateReceiver.java

public static void trigger(final Context context) {
    if (lastUpdate < System.currentTimeMillis() - 1000L) {
        new UpdateReceiver().updateNotification(context);
    }/*from   ww w .  j  a  va  2s  . c o m*/
    context.sendBroadcast(new Intent(context, UpdateReceiver.class));
}

From source file:org.kegbot.app.service.CheckinService.java

public static void requestImmediateCheckin(Context context) {
    final Intent intent = getCheckinIntent(context);
    context.sendBroadcast(intent);
}

From source file:Main.java

/**
 * Save an image URI into the gallery//  ww  w .  j av a 2 s.  c o  m
 * @param context the context.
 * @param sourceFile the image path to save.
 */
public static String saveImageIntoGallery(Context context, File sourceFile) {
    String filePath = saveFileInto(context, sourceFile, Environment.DIRECTORY_PICTURES, null);

    if (null != filePath) {
        // This broadcasts that there's been a change in the media directory
        context.sendBroadcast(
                new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(filePath))));
    }

    return filePath;
}

From source file:Main.java

/**
 * Set badge count//from w w  w .ja  v  a 2s .c  om
 * 
 * @param context The context of the application package.
 * @param count Badge count to be set
 */
public static void setBadgeCount(Context context, int count) {
    Intent badgeIntent = new Intent(ACTION_BADGE_COUNT_UPDATE);
    badgeIntent.putExtra(EXTRA_BADGE_COUNT, count);
    badgeIntent.putExtra(EXTRA_BADGE_COUNT_PACKAGE_NAME, context.getPackageName());
    badgeIntent.putExtra(EXTRA_BADGE_COUNT_CLASS_NAME, getLauncherClassName(context));
    context.sendBroadcast(badgeIntent);
}