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 updateIconBadge(Context context, int notiCnt) {
    Intent badgeIntent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
    badgeIntent.putExtra("badge_count", notiCnt);
    badgeIntent.putExtra("badge_count_package_name", context.getPackageName());
    badgeIntent.putExtra("badge_count_class_name", getLauncherClassName(context));
    context.sendBroadcast(badgeIntent);
}

From source file:Main.java

/**
 * Set badge count// w  w w .j av a 2  s  . c  o  m
 *
 * @param context The context of the application package.
 * @param count   Badge count to be set
 */
private static void setBadgeCount4Default(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);
}

From source file:Main.java

public static void notifyPlayStateChanged(Context ctx, boolean playing, long position) {
    // The bluetooth stuff assumes STOP if playing == false && position = 0, PAUSE if
    // playing == false && position > 0, and PLAYING if playing == true
    Intent i = new Intent(AVRCP_PLAYSTATE_CHANGED);
    i.putExtra(KEY_PLAYING, playing);/*from   w w w.j  av a 2 s .c  om*/
    i.putExtra(KEY_POSITION, position);

    ctx.sendBroadcast(i);
}

From source file:com.appnexus.opensdk.PBImplementation.java

private static void sendBroadcast(Context context, String auctionInfo, byte[] imageBytes) {
    String dataUrl = URL_BROADCAST_PREFIX + Uri.encode(auctionInfo);

    Intent intent = new Intent(ACTION_BROADCAST, Uri.parse(dataUrl));
    intent.putExtra(KEY_IMAGE, imageBytes);
    context.sendBroadcast(intent);
}

From source file:hobby.wei.c.framework.EventDelegater.java

public static void sendGlobalEvent(Context context, String eventName, Bundle data) {
    Intent intent = new Intent(AbsApp.get().withPackageNamePrefix(eventName));
    if (data != null)
        intent.putExtra(KEY_BUNDLE_EVENT, data);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void ask_for_payment(Context context, String payee_id, String annotation, String channel_id,
        String callback_url, int amount) {
    Intent intent = new Intent(CONFIRM_PAYMENT_ACTION);
    intent.putExtra("payee_id", payee_id);
    intent.putExtra("annotation", annotation);
    intent.putExtra("channel_id", channel_id);
    intent.putExtra("callback_url", callback_url);
    intent.putExtra("amount", amount);
    context.sendBroadcast(intent);
    Log.v(LOG_TAG, "send intent to main activity to confirm payment");
}

From source file:tw.com.ksmt.cloud.libs.Utils.java

public static void bcastMessage(Context context, String message) {
    Intent intent = new Intent(PrjCfg.BRCAST_MSG);
    intent.putExtra(PrjCfg.BRCAST_MSG, message);
    context.sendBroadcast(intent);
}

From source file:org.klnusbaum.udj.network.RESTProcessor.java

private static void checkVolume(Context context, AccountManager am, Account account, int volume) {
    if (Utils.getPlayerVolume(am, account) != volume) {
        am.setUserData(account, Constants.PLAYER_VOLUME_DATA, String.valueOf(volume));
        Intent playerVolumeChangedBroadcast = new Intent(Constants.BROADCAST_VOLUME_CHANGED);
        playerVolumeChangedBroadcast.putExtra(Constants.PLAYER_VOLUME_EXTRA, volume);
        context.sendBroadcast(playerVolumeChangedBroadcast);
    }/*from   www  .  jav  a  2s  .  c  o m*/
}

From source file:com.onesignal.NotificationOpenedProcessor.java

public static void processFromActivity(Context inContext, Intent inIntent) {
    // Pressed an action button, need to clear the notification and close the notification area manually.
    if (inIntent.getBooleanExtra("action_button", false)) {
        NotificationManagerCompat.from(inContext).cancel(inIntent.getIntExtra("notificationId", 0));
        inContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
    }//from   w ww. j  a  v a 2s  .c  om

    processIntent(inContext, inIntent);
}

From source file:Main.java

public static void setBadge(Context context, int count) {
    String launcherClassName = getLauncherClassName(context);
    if (launcherClassName == null) {
        return;/*from  w  ww  .jav  a2s .c  o m*/
    }
    Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
    intent.putExtra("badge_count", count);
    intent.putExtra("badge_count_package_name", context.getPackageName());
    intent.putExtra("badge_count_class_name", launcherClassName);
    context.sendBroadcast(intent);
}