List of usage examples for android.content Context sendBroadcast
public abstract void sendBroadcast(@RequiresPermission Intent intent);
From source file:Main.java
public static void Broadcast(String action, Bundle bundle, Context context) { Intent intent = new Intent(); intent.setAction(action);//w w w. ja v a 2 s .c om if (bundle != null) { intent.putExtras(bundle); } context.sendBroadcast(intent); }
From source file:Main.java
public static void scanPhotos(String filePath, Context context) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri uri = Uri.fromFile(new File(filePath)); intent.setData(uri);//from w ww . j a va 2 s .co m context.sendBroadcast(intent); }
From source file:Main.java
public static void refreshGallery(Context context, Uri uri) { Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); final Uri contentUri = uri; scanIntent.setData(contentUri);/*from w ww .ja v a2s.c om*/ context.sendBroadcast(scanIntent); }
From source file:Main.java
public static void sendBroadcast(Context context, String action, String extra, int value) { Intent broadcast = new Intent(); broadcast.setAction(action);/*from w w w . j av a 2s .c om*/ broadcast.putExtra(extra, value); context.sendBroadcast(broadcast); }
From source file:Main.java
/** * Notifies UI to display a message./*from w w w. ja v a 2 s.com*/ * <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); intent.putExtra(EXTRA_MESSAGE, message); context.sendBroadcast(intent); }
From source file:Main.java
private static void addTomMediaScanner(Context context, Uri uri) { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); mediaScanIntent.setData(uri);//w w w .j a v a 2 s . c om context.sendBroadcast(mediaScanIntent); }
From source file:Main.java
public static void scanMediaFileToGallery(Context context, String path) { File file = new File(path); Uri uri = Uri.fromFile(file);/* ww w . j ava2 s . c om*/ Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri); context.sendBroadcast(intent); }
From source file:Main.java
public static void pauseMusic(Context context) { Intent freshIntent = new Intent(); freshIntent.setAction("com.android.music.musicservicecommand.pause"); freshIntent.putExtra("command", "pause"); context.sendBroadcast(freshIntent); }
From source file:Main.java
public static void displayMessage(Context context, String message) { // TODO: Used for basic popup messages. Intent intent = new Intent(DISPLAY_MESSAGE_ACTION); intent.putExtra(EXTRA_MESSAGE, message); context.sendBroadcast(intent); }
From source file:Main.java
public static void insertImageToPhotoAlbum(Context context, String fileName) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri uri = Uri.fromFile(new File(fileName)); intent.setData(uri);/*from ww w . j av a 2 s. c o m*/ context.sendBroadcast(intent); }