本文整理汇总了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())));
}
}
}
示例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
}
}
}
示例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();
}
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例15: refreshAudio
private void refreshAudio(File file) {
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
mediaScanIntent.setData(Uri.fromFile(file));
sendBroadcast(mediaScanIntent);
}