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

/**
 * @param message to open the camera./*from   www . j  a  va2 s  . c om*/
 *  
 *  
 */
static void openCamera(Context context, String message) {
    Intent intent = new Intent(CAMERA_OPEN_ACTION);
    // intent.putExtra(EXTRA_MESSAGE, message);
    intent.getAction();
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void reboot(Context context) {

    Intent intent = new Intent(Intent.ACTION_REBOOT);
    intent.putExtra("nowait", 1);
    intent.putExtra("interval", 1);
    intent.putExtra("window", 0);
    context.sendBroadcast(intent);

}

From source file:Main.java

private static void sendActionCommand(Context ctx, String action, Bundle extras) {
    Intent intent = new Intent();
    intent.setAction(action);/*  w ww. j av a2  s . c om*/
    if (extras != null) {
        intent.putExtras(extras);
    }
    ctx.sendBroadcast(intent);
}

From source file:Main.java

public static void scanPic(Context context, File file) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    Uri contentUri = Uri.fromFile(file);
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
}

From source file:Main.java

/**
 * Notifies UI to display a message./*from  w w w .  j  ava 2s  .  c  o m*/
 * <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.
 */
static void displayMessage(Context context, String message) {
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    Log.d("GCM", message);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}

From source file:Main.java

/**
 * Notifies UI to display a message. This method is defined in the common
 * helper because it's used both by the UI and the background service.
 *
 * @param context The application context.
 * @param message The message to be displayed.
 *//*from   w  ww .  java2s  . co m*/
public static void displayMessage(Context context, String message) {
    Log.i(TAG, "displayMessage: " + message);
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}

From source file:Main.java

/**
 * Notifies UI to display a message. This method is defined in the common
 * helper because it's used both by the UI and the background service.
 *
 * @param context The application context.
 * @param message The message to be displayed.
 *///from  ww w  . j  a  v a 2 s  . c  o  m
public static void displayMessage(Context context, String message) {
    Log.i(TAG, "displayMessage(): " + message);
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}

From source file:Main.java

/**
 * Add file photo to gallery after capture from camera or downloaded.
 *
 * @param context/*from  w  w  w  .j  a  va  2s . c om*/
 * @param file
 */
public static void galleryAddPic(Context context, File file) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    Uri contentUri = Uri.fromFile(file);
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
}

From source file:org.wahtod.wififixer.utility.BroadcastHelper.java

public static void sendBroadcast(Context c, Intent i, boolean local) {
    if (local)/*from w  w  w . j  ava2s. c  o m*/
        LocalBroadcastManager.getInstance(c).sendBroadcast(i);
    else
        c.sendBroadcast(i);
}

From source file:Main.java

/**
 * Notifies UI to display a message.//from   ww w . j  a  va 2 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.
 */
static void displayMessage(Context context, String message, String numb) {
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_NUMBER, numb);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}