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 globalAppsMediaScanIntent(Context context, String imageFullPath) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    File f = new File(imageFullPath);
    Uri contentUri = Uri.fromFile(f);//from  w w  w .  ja v a2  s  .  co m
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
}

From source file:Main.java

public static void scanPhoto(Context ctx, String imgFileName) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    File file = new File(imgFileName);
    Uri contentUri = Uri.fromFile(file);
    mediaScanIntent.setData(contentUri);
    ctx.sendBroadcast(mediaScanIntent);
}

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

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

From source file:Main.java

public static void removeShortCut(Context context, String appName, Intent tagIntent) {
    Intent intent = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");
    intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, appName);
    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, tagIntent);
    context.sendBroadcast(intent);
}

From source file:Main.java

/**
 * Helper method for adding the photo to the system photo gallery so it can be accessed
 * from other apps.// w ww. j a v a2s .  com
 *
 * @param imagePath The path of the saved image
 */
private static void galleryAddPic(Context context, String imagePath) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    File f = new File(imagePath);
    Uri contentUri = Uri.fromFile(f);
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
}

From source file:Main.java

public static void sendBrodcast(Context context, String action, Bundle bundle) {
    if (TextUtils.isEmpty(action) || context == null) {
        return;/*  ww w. j  a  va  2  s .  c  o  m*/
    }
    Intent intent = new Intent();
    intent.setAction(action);
    intent.putExtra("extra", bundle);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void sendBroadcast(Context context, String filter, Bundle bundle) {
    if (context == null) {
        return;/*  w  w w. j  a  va2s.  com*/
    }
    Intent intent = new Intent();
    intent.setAction(filter);
    intent.putExtras(bundle);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void sendBrodcast(Context context, String action, String content) {
    if (TextUtils.isEmpty(action) || context == null) {
        return;//from www  .  ja  v a  2s  .c om
    }
    Intent intent = new Intent();
    intent.setAction(action);
    intent.putExtra("extra", content);
    context.sendBroadcast(intent);
}

From source file:Main.java

private static void scanPhoto(Context ctx, String imgFileName) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    File file = new File(imgFileName);
    Uri contentUri = Uri.fromFile(file);
    mediaScanIntent.setData(contentUri);
    ctx.sendBroadcast(mediaScanIntent);
}

From source file:com.fgl.calc.tools.Tools.java

public static void SendBroadcast(String action, Context context) {
    final Intent NewIntent = new Intent();
    NewIntent.setAction(action);/* ww w  .  j a  va 2  s  . com*/
    context.sendBroadcast(NewIntent);
}