当前位置: 首页>>代码示例>>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;未经允许,请勿转载。