當前位置: 首頁>>代碼示例>>Java>>正文


Java Intent.ACTION_MEDIA_SCANNER_SCAN_FILE屬性代碼示例

本文整理匯總了Java中android.content.Intent.ACTION_MEDIA_SCANNER_SCAN_FILE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Intent.ACTION_MEDIA_SCANNER_SCAN_FILE屬性的具體用法?Java Intent.ACTION_MEDIA_SCANNER_SCAN_FILE怎麽用?Java Intent.ACTION_MEDIA_SCANNER_SCAN_FILE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.content.Intent的用法示例。


在下文中一共展示了Intent.ACTION_MEDIA_SCANNER_SCAN_FILE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkFile

/**
 * 檢查保存的文件並且更新到相冊
 */
private void checkFile() {
    if (mFile.exists()) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
            mediaScanIntent.setData(Uri.fromFile(mFile));
            getContext().sendBroadcast(mediaScanIntent);
        } else {
            getContext().sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse(mFile.getPath())));
        }
    }
}
 
開發者ID:sunshinecoast,項目名稱:ScreenRecordCaptureMaster,代碼行數:14,代碼來源:RecordScreenDialog.java

示例2: importWallets

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

        }
    }
}
 
開發者ID:manuelsc,項目名稱:Lunary-Ethereum-Wallet,代碼行數:19,代碼來源:WalletStorage.java

示例3: updateMediaStore

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();
    }
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:20,代碼來源:FileUtils.java

示例4: requestIndexing

/**
 * set hidden false when reindex is true
 * */

public static void requestIndexing(Uri uri, Context context, boolean reIndex) {
    if (uri == null || context == null) {
        Log.w(TAG, "requestIndexing: file or context null");
        return;
    }
    //first check if video is hidden
    if(reIndex) {
        Uri tmp = uri;
        if ("file".equals(tmp.getScheme())) {
            tmp = Uri.parse(uri.toString().substring("file://".length()));
        }
        String whereR = VideoStore.MediaColumns.DATA + " = ?";
        final ContentValues cvR = new ContentValues(1);
        String col = VideoStore.Video.VideoColumns.ARCHOS_HIDDEN_BY_USER;
        cvR.put(col, 0);
        context.getContentResolver().update(VideoStore.Video.Media.EXTERNAL_CONTENT_URI, cvR, whereR, new String[]{tmp.toString()});
    }
    String action;
    if ((!Utils.isLocal(uri)||UriUtils.isContentUri(uri))&& UriUtils.isIndexable(uri)) {
        action = ArchosMediaIntent.ACTION_VIDEO_SCANNER_SCAN_FILE;
    }
    else {
        action = Intent.ACTION_MEDIA_SCANNER_SCAN_FILE;
        if(uri.getScheme()==null)
            uri = Uri.parse("file://"+uri.toString());
    }
    Intent scanIntent = new Intent(action);
    scanIntent.setData(uri);
    if(!UriUtils.isContentUri(uri)) // doesn't work with content
        context.sendBroadcast(scanIntent);
    else
        NetworkScannerServiceVideo.startIfHandles(context, scanIntent);
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:37,代碼來源:VideoStore.java

示例5: exportWallet

private boolean exportWallet(Activity c, boolean already) {
    if (walletToExport == null) return false;
    if (walletToExport.startsWith("0x"))
        walletToExport = walletToExport.substring(2);

    if (ExternalStorageHandler.hasPermission(c)) {
        File folder = new File(Environment.getExternalStorageDirectory(), "Lunary");
        if (!folder.exists()) folder.mkdirs();

        File storeFile = new File(folder, walletToExport + ".json");
        try {
            copyFile(new File(c.getFilesDir(), walletToExport), storeFile);
        } catch (IOException e) {
            return false;
        }

        // fix, otherwise won't show up via USB
        Intent mediaScannerIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
        Uri fileContentUri = Uri.fromFile(storeFile); // With 'permFile' being the File object
        mediaScannerIntent.setData(fileContentUri);
        c.sendBroadcast(mediaScannerIntent); // With 'this' being the context, e.g. the activity
        return true;
    } else if (!already) {
        ExternalStorageHandler.askForPermission(c);
        return exportWallet(c, true);
    } else {
        return false;
    }
}
 
開發者ID:manuelsc,項目名稱:Lunary-Ethereum-Wallet,代碼行數:29,代碼來源:WalletStorage.java

示例6: addPicToGallery

private void addPicToGallery() {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    File f = new File(photoPath);
    Uri contentUri = Uri.fromFile(f);
    mediaScanIntent.setData(contentUri);
    this.sendBroadcast(mediaScanIntent);
}
 
開發者ID:micromasterandroid,項目名稱:androidadvanced,代碼行數:7,代碼來源:MainActivity.java

示例7: notifyGallery

/**
 * 通知係統相冊更新
 * @param context
 * @param filePath
 */
public static void notifyGallery(Context context,String filePath) {
    Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    Uri uri = Uri.fromFile(new File(filePath));
    intent.setData(uri);
    context.sendBroadcast(intent);
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:11,代碼來源:BitmapCommonUtils.java

示例8: galleryAddPic

/**
 * 添加到圖庫
 */
public static void galleryAddPic(Context context, String path) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    File f = new File(path);
    Uri contentUri = Uri.fromFile(f);
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:10,代碼來源:PictureUtil.java

示例9: galleryAddPic

private void galleryAddPic() {
    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);
}
 
開發者ID:iamjaspreetsingh,項目名稱:TrackPlan-app,代碼行數:7,代碼來源:addstudpicActivity.java

示例10: addMediaToGallery

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("tmessages", e);
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:12,代碼來源:AndroidUtilities.java

示例11: galleryAddPic

public void galleryAddPic() {
  Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);

  if (TextUtils.isEmpty(mCurrentPhotoPath)) {
    return;
  }

  File f = new File(mCurrentPhotoPath);
  Uri contentUri = Uri.fromFile(f);
  mediaScanIntent.setData(contentUri);
  mContext.sendBroadcast(mediaScanIntent);
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:12,代碼來源:ImageCaptureManager.java

示例12: refreshGallery

private void refreshGallery(Uri contentUri) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    mediaScanIntent.setData(contentUri);
    this.cordova.getActivity().sendBroadcast(mediaScanIntent);
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:5,代碼來源:CameraLauncher.java

示例13: broadcastNewFile

/**
 * 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);
}
 
開發者ID:rodrigonsh,項目名稱:alerta-fraude,代碼行數:7,代碼來源:LocalFilesystem.java

示例14: sendBrodcast4Update

private void sendBrodcast4Update(File file) {
    Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    Uri uri = Uri.fromFile(file);
    intent.setData(uri);
    sendBroadcast(intent);
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:6,代碼來源:DonateActivity.java

示例15: refreshAudio

private void refreshAudio(File file) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    mediaScanIntent.setData(Uri.fromFile(file));
    sendBroadcast(mediaScanIntent);
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:5,代碼來源:AudioRecorderActivity.java


注:本文中的android.content.Intent.ACTION_MEDIA_SCANNER_SCAN_FILE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。