Java Code Examples for android.content.Intent#ACTION_MEDIA_SCANNER_SCAN_FILE
The following examples show how to use
android.content.Intent#ACTION_MEDIA_SCANNER_SCAN_FILE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SingleMediaScanner.java From cordova-rtmp-rtsp-stream with Apache License 2.0 | 8 votes |
@Override public void onScanCompleted(String path, Uri uri) { Log.i("SingleMediaScanner", path); Log.i("SingleMediaScanner", uri.getPath()); mMs.disconnect(); MediaScannerConnection.scanFile(mContext, new String[] { mFile.getAbsolutePath() }, new String[] { "video/*" }, null); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); mediaScanIntent.setData(Uri.fromFile(mFile)); mContext.sendBroadcast(mediaScanIntent); } else { mContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse(mFile.getAbsolutePath()))); } }
Example 2
Source File: WalletStorage.java From bcm-android with GNU General Public License v3.0 | 6 votes |
public void importWallets(Context c, ArrayList<File> toImport) throws Exception { for (int i = 0; i < toImport.size(); i++) { String address = stripWalletName(toImport.get(i).getName()); if (address.length() == 40) { copyFile(toImport.get(i), new File(c.getFilesDir(), address)); if (!BuildConfig.DEBUG) toImport.get(i).delete(); WalletStorage.getInstance(c).add(new FullWallet("0x" + address, address), c); AddressNameConverter.getInstance(c).put("0x" + address, "Wallet " + ("0x" + address).substring(0, 6), c); Intent mediaScannerIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri fileContentUri = Uri.fromFile(toImport.get(i)); // With 'permFile' being the File object mediaScannerIntent.setData(fileContentUri); c.sendBroadcast(mediaScannerIntent); // With 'this' being the context, e.g. the activity } } }
Example 3
Source File: FileUtils.java From FireFiles with Apache License 2.0 | 6 votes |
public static void updateMediaStore(Context context, ArrayList<DocumentInfo> docs, String parentPath) { try { if(Utils.hasKitKat()){ ArrayList<String> paths = new ArrayList<>(); for(DocumentInfo doc : docs){ paths.add(parentPath + File.separator + doc.displayName); } String[] pathsArray = paths.toArray(new String[paths.size()]); FileUtils.updateMediaStore(context, pathsArray); } else{ Uri contentUri = Uri.fromFile(new File(parentPath).getParentFile()); Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, contentUri); context.sendBroadcast(mediaScanIntent); } } catch (Exception e){ e.printStackTrace(); } }
Example 4
Source File: AndroidUtilities.java From Telegram with GNU General Public License v2.0 | 5 votes |
public static void addMediaToGallery(Uri uri) { if (uri == null) { return; } try { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); mediaScanIntent.setData(uri); ApplicationLoader.applicationContext.sendBroadcast(mediaScanIntent); } catch (Exception e) { FileLog.e(e); } }
Example 5
Source File: AndroidUtilities.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public static void addMediaToGallery(Uri uri) { if (uri == null) { return; } try { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); mediaScanIntent.setData(uri); ApplicationLoader.applicationContext.sendBroadcast(mediaScanIntent); } catch (Exception e) { FileLog.e(e); } }
Example 6
Source File: Utilities.java From Yahala-Messenger with MIT License | 5 votes |
public static void addMediaToGallery(Uri uri) { if (uri == null) { return; } Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); mediaScanIntent.setData(uri); ApplicationLoader.applicationContext.sendBroadcast(mediaScanIntent); }
Example 7
Source File: MediaStoreUtils.java From SimpleExplorer with GNU General Public License v3.0 | 5 votes |
public static void addFileToMediaStore(final String path, Context context) { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); File file = new File(path); Uri contentUri = Uri.fromFile(file); mediaScanIntent.setData(contentUri); context.sendBroadcast(mediaScanIntent); }
Example 8
Source File: ImageTransferFragment.java From Bluefruit_LE_Connect_Android_V2 with MIT License | 5 votes |
private void addPictureToGallery(@NonNull Context context, @NonNull String photoPath) { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); try { File f = new File(photoPath); Uri contentUri = Uri.fromFile(f); mediaScanIntent.setData(contentUri); context.sendBroadcast(mediaScanIntent); } catch (NullPointerException e) { Log.e(TAG, "Error opening file: " + photoPath); } }
Example 9
Source File: MediaStoreUtil.java From Augendiagnose with GNU General Public License v2.0 | 5 votes |
/** * Add a picture to the media store (via scanning). * * @param path the path of the image. */ public static void addPictureToMediaStore(@NonNull final String path) { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); File file = new File(path); Uri contentUri = Uri.fromFile(file); mediaScanIntent.setData(contentUri); Application.getAppContext().sendBroadcast(mediaScanIntent); }
Example 10
Source File: DownloadImage.java From Android with MIT License | 5 votes |
private void galleryAddPic(String imagePath) { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); File f = new File(imagePath); image_path = Uri.fromFile(f); mediaScanIntent.setData(image_path); mContext.sendBroadcast(mediaScanIntent); }
Example 11
Source File: SignaturePadActivity.java From UltimateAndroid with Apache License 2.0 | 5 votes |
public boolean addSignatureToGallery(Bitmap signature) { boolean result = false; try { File photo = new File(getAlbumStorageDir("SignaturePad"), String.format("Signature_%d.jpg", System.currentTimeMillis())); saveBitmapToJPG(signature, photo); Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri contentUri = Uri.fromFile(photo); mediaScanIntent.setData(contentUri); sendBroadcast(mediaScanIntent); result = true; } catch (IOException e) { e.printStackTrace(); } return result; }
Example 12
Source File: MainActivity.java From cosu with Apache License 2.0 | 5 votes |
private void setImageToView(){ //Save the file in gallery Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); File f = new File(mCurrentPhotoPath); Uri contentUri = Uri.fromFile(f); mediaScanIntent.setData(contentUri); this.sendBroadcast(mediaScanIntent); // Get the dimensions of the view int targetH = imageView.getMaxHeight(); int targetW = imageView.getMaxWidth(); // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions); int photoH = bmOptions.outHeight; int photoW = bmOptions.outWidth; // Determine how much to scale down image int scaleFactor = Math.min(photoW/targetW, photoH/targetH); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; Bitmap imageBitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions); imageView.setImageBitmap(imageBitmap); // enable lock task button lockTaskButton.setEnabled(true); }
Example 13
Source File: StorageUtils.java From Camdroid with Apache License 2.0 | 4 votes |
public static void updateMedia(Context ctx, File file) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(file)); ctx.sendBroadcast(intent); }
Example 14
Source File: FileSystem.java From pixelvisualcorecamera with Apache License 2.0 | 4 votes |
/** * Notifies system there is a new media file, so that it appears in photo galleries immediately. */ private static void updateMediaStore(Context context, File file) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); intent.setData(Uri.fromFile(file)); context.sendBroadcast(intent); }
Example 15
Source File: FileUtils.java From mytracks with Apache License 2.0 | 4 votes |
public static void updateMediaScanner(Context context, Uri uri) { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); mediaScanIntent.setData(uri); context.sendBroadcast(mediaScanIntent); }
Example 16
Source File: MainActivity.java From android-palette with Apache License 2.0 | 4 votes |
private static void scanFile(Context context, String filePath) { Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); scanIntent.setData(Uri.fromFile(new File(filePath))); context.sendBroadcast(scanIntent); }
Example 17
Source File: LocalFilesystem.java From reacteu-app with MIT License | 4 votes |
/** * Send broadcast of new file so files appear over MTP */ private void broadcastNewFile(Uri nativeUri) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, nativeUri); context.sendBroadcast(intent); }
Example 18
Source File: GankIoActivity.java From styT with Apache License 2.0 | 4 votes |
private static void sendPictureStoredBroadcast(Context context, String qrSavePath) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri uri = Uri.fromFile(new File(qrSavePath)); intent.setData(uri); context.sendBroadcast(intent); }
Example 19
Source File: MediaUtil.java From BaseProject with Apache License 2.0 | 4 votes |
/** * 通过广播的方式通知系统扫描某个文件 * @param appContext appContext * @param filePath 要被扫描的文件路径 */ public static void notifySysScanFile(Context appContext, String filePath) { Uri data = Uri.parse("file://" + filePath); Intent toScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, data); appContext.sendBroadcast(toScanIntent); }
Example 20
Source File: FloatingBallUtils.java From RelaxFinger with GNU General Public License v2.0 | 2 votes |
/** * 通知媒体库更新文件 * @param context * @param filePath 文件全路径 * * */ public static void scanFile(Context context, String filePath) { Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); scanIntent.setData(Uri.fromFile(new File(filePath))); context.sendBroadcast(scanIntent); }