android-mediascanner

MediaScannerConnection#scanFile converts directories into files when accessing them with USB-MTP on Android 5 Lollipop

流过昼夜 提交于 2019-11-28 03:35:40
问题 Changes like renaming a file triggered by an app only appear to the USB-MTP interface after reboot of the Android device or after you registered the new file at the MediaScanner them like this (see Trigger mediascanner on specific path (folder), how to?): file.renameTo(newFile); MediaScannerConnection.scanFile(context, new String[] { newFile.getAbsolutePath() }, null, null); USB-MTP is used to access the storage of an android device via USB. E.g. with the Windows Explorer. However, with the

Refresh Android mediastore using adb

非 Y 不嫁゛ 提交于 2019-11-28 03:08:37
I'm using adb to sync music on an android phone. Essentially, I rm the existing music directory and push replacement music files. I'd like to be able to use adb to force a rescan, so that the google music player (and other apps) works properly with the new songs and playlists. According to How can I refresh MediaStore on Android? you can force a rescan by broadcasting an appropriate intent. adb provides 'shell am broadcast', which would seem to allow me to force a rescan from adb. Alternatively I could run a rescan app or reboot, but I'd like to trigger the rescan from adb What adb command

how to get frames of video file in android

怎甘沉沦 提交于 2019-11-28 02:26:32
I want to get the frames of a video file to show in a gallery view in android. and how to edit frames, for example Select frame sections use selected sections delete selected sections copy selected sections cut selected sections paste into the head paste into the tail You can use the MediaMetadataRetriever class. It has getFrameAt() method wherein you can specify the time of the frame that you want to get. For details refer to MediaMetadataRetriever Actually, MediaMetadataRetriever.getFrameAtTime uses microseconds as a parameter, not milliseconds. Once you make that change, you can get the

File not added to gallery android

邮差的信 提交于 2019-11-28 02:06:53
问题 This app i am making is taking pictures and saving it to sdcard but the images are not being shown in gallery...Is there something wrong with my code public void takepicture(View view){ try{ String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { //To store public files File directory=new File(Environment.getExternalStorageDirectory() , "Myapp Pictures"); if(!directory.exists()) directory.mkdir(); // Create an image file name String timeStamp = new

How to trigger MediaScan on Nexus 7?

我们两清 提交于 2019-11-27 14:31:10
Because I want to make sure the MediaStore has the latest information without having to reboot I'd like to trigger the MediaScanner using the popular way I found on SO context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); This works fine on my Samsung S2 w/ICS but not on my Nexus 7 w/JellyBean. Logcat shows this on my Nexus 7: WARN/ActivityManager(480): Permission denied: checkComponentPermission() owningUid=10014 WARN/BroadcastQueue(480): Permission Denial: broadcasting Intent { act=android.intent.action.MEDIA_MOUNTED

Force scan files after taking photo

杀马特。学长 韩版系。学妹 提交于 2019-11-27 14:14:47
on api level 4 (android 1.6), after taking photo using: Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); File photo = new File(Environment.getExternalStorageDirectory(), "NewPic.jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); imageUri = Uri.fromFile(photo); startActivityForResult(intent, TAKE_PICTURE); I'd like to look through all my photos thumbnails, but there is no my last photo thumbnail. It works perfectly on android 2.1. If I connect device via USB to PC and then disconnect file will appear, after finished scanning. So how should I start that

Observing changes in Android content observer for Audio.Media.EXTERNAL_CONTENT_URI

时光总嘲笑我的痴心妄想 提交于 2019-11-27 02:50:57
问题 I am developing an Android app in which I have to detect changes in Android SD card for audio files with the file name, file path and operation performed upon it. Example if I am adding a file in my SD card then I want to know Name of the file which is added Path of the file Operation -- Add Previously I Have tried file observer But for that I have to apply it on each and every directory. So I searched for some other solution and got the info about Audio.Media.EXTERNAL_CONTENT_URI . Then I

Android's Media Scanner: How do I remove files?

﹥>﹥吖頭↗ 提交于 2019-11-27 01:29:23
问题 I'm writing an app that removes files that may or may not be listed in any one of the types of media libraries such as music or pictures. While I can use the MediaScannerConnection.scanFile method to add files to the media library there doesn't seem to be any call to notify the service that the file has been removed. Sending it the path of the file that no longer exists doesn't result in the desired behavior either. How should I go about removing items from the library that no longer exist on

Refresh Android mediastore using adb

和自甴很熟 提交于 2019-11-26 23:57:32
问题 I'm using adb to sync music on an android phone. Essentially, I rm the existing music directory and push replacement music files. I'd like to be able to use adb to force a rescan, so that the google music player (and other apps) works properly with the new songs and playlists. According to How can I refresh MediaStore on Android? you can force a rescan by broadcasting an appropriate intent. adb provides 'shell am broadcast', which would seem to allow me to force a rescan from adb.

how to run media scanner in android

孤街醉人 提交于 2019-11-26 18:50:33
I want run the media scanner while capturing the image. After capturing, the image it is updated in grid view. For that I need to run media scanner. I found two solutions to run media scanner one is the broadcast event and other one is running media scanner class. I think in Ice Cream Sandwich (4.0) media scanner class is introduced.Before versions need to set broadcast event for running media scanner. can any one guide me how to run media scanner in right way. I have found it best (faster/least overhead) to run media scanner on a specific file (vs running it to scan all files for media), if