[Q] Access SD media scan? - Android Software Development

Hi all,
I'm making a port of my homebrew for PSP named Musikr. but I'm having some problems while trying to scan the SD Card for songs (Don't know why, when using recursion, always get FC :S). So I thought that maybe I could access to the files Android auto-scans for when inserting an sd. But the thing is that, regardless all the info I've looked for, still don't know how to do that (even if that can be done).
So, does anyone know how to do that?
Thanks in advance

Android stores all the content it finds with the media scanner in the media content provider (basically a collection of sqlite databases/tables).
http://developer.android.com/guide/topics/providers/content-providers.html
For example the music is stored here:
http://developer.android.com/reference/android/provider/MediaStore.Audio.Media.html
You can read that database pretty easily to find all the content/media you need.
You can also register a broadcast receiver for the MediaScanner complete event to notify you if the media scanner has just completed scanning the SD card.
The intent names are:
android.intent.action.MEDIA_SCANNER_STARTED
android.intent.action.MEDIA_SCANNER_FINISHED
android.intent.action.MEDIA_SCANNER_SCAN_FILE
but you have to set the data attribute in the intent-filter in your manifest as well
like so:
<data android:scheme="file" />

Related

Reference Page for Folder Structure in HD2

hello everybody,
i am searching here for a while and couldn´t find any helpful webpage or forum thread here that shows me, where are the standard folders located ( registry settings ) in WM6.5 or in special for the HTC HD2.
i would like to re-arrange any folder for media files ( ringtones, mp3-music, videos,documents, ebook and so on....)
to an easier structure in \\storage card and saving memory/space in mydevice
for that reason i´d like to know where are folders for what reason of standard-copy paths in \\mydevice and \\storagecard to erase un-needed things and avoid duplicating
the goal is to have easier folders to locate files
like
\\strorage card\Pictures
\\strorage card\Videos
\\strorage card\Music
\\strorage card\Ringtones
\\strorage card\Documents
and make sure that standard applications use that new paths for managing
i think i am not the only person who is interested in that, otherwise sorry for disturbing
thank you
PS
Everything you mentioned happened to be under \\My Documents. They are part of file sync to Windows.
It is a bad idea to place ring tones on SD card. It probably won't work.
thanks for that info.
that was indeed my intention also to change ringtones to storagecard. i am aware that didnt´ work , but with changing reg-keys maybe..any idea where they are ?
Yeah, don't put anything on the storage card that your device might need at any given time. Even if you never remove your card, it won't always be available when needed. For instance, when your device wakes up from an incoming phone call, it can't access the storage card right away since it may take a moment to activate the reader. Therefore it might not be able to use a ringtone stored there.
For the same reason, I wouldn't redirect the "standard" locations to the storage card through a registry change if I were you. You never know how the device will react if it wakes up and doesn't find its "My Documents" folder right away.
Other than that, it doesn't really matter where you put your media files: most of the built-in applications look for them everywhere. So if you want to save internal storage space, you can move most media stuff to your storage card without redirecting the default folders.
For music, I'd say go for "\\strorage card\Music", since that's where music files are automatically stored when you sync with Windows Media Player on the desktop.
For pictures, you might want to use "\\strorage card\DCIM\100MEDIA", since that's where the camera puts new photo's; but "\\strorage card\Pictures" will work just as well. HTC Album will pick up pics anywhere you put them. You can even choose which folder to display in the Sense tab. From the Sense tab, just go to > "Album" > "Albums", pick the one you want, then > "Menu" > "Set as favorite".
As you can see, these will work without redirecting the default folders to your storage card. If, however, you want to try anyway and don't mind the risk of experimenting, the content of this registry key looks promising:
HKEY_LOCAL_MACHINE\System\Explorer\Shell Folders
Good luck!
If you want to change the location where the camera stores new pics, you might want to look at this key:
HKEY_LOCAL_MACHINE/System/Pictures/Camera/OEM/PictureLocation
But again: I haven't tried this, so use at your own risk!
Robrecht said:
For music, I'd say go for "\\strorage card\Music", since that's where music files are automatically stored when you sync with Windows Media Player on the desktop.
For pictures, you might want to use "\\strorage card\DCIM\100MEDIA", since that's where the camera puts new photo's; but "\\strorage card\Pictures" will work just as well. HTC Album will pick up pics anywhere you put them. You can even choose which folder to display in the Sense tab. From the Sense tab, just go to > "Album" > "Albums", pick the one you want, then > "Menu" > "Set as favorite".
As you can see, these will work without redirecting the default folders to your storage card. If, however, you want to try anyway and don't mind the risk of experimenting, the content of this registry key looks promising:
HKEY_LOCAL_MACHINE\System\Explorer\Shell Folders
Good luck!
Click to expand...
Click to collapse
thanks for that imput, thats what i need for get the knot out of my brain :=)
thanks so much...i will try that hints.

[Q] Media scanner issue / gallery broken

Is there any way to fix the media scanner so the gallery can be used? Does anyone know why it's broken? Lots of apps require the Gallery.
Yes, the MediaScanner on the Nook is pretty stupid.
I see logcats occasionally of it finding things.
In our 2.1 you can't even invoke it on a directory, only a file.
I gave up using it as a source for book information and do my own scanning.
I haven't looked into why it doesn't work as well as it should.
Renate NST said:
Yes, the MediaScanner on the Nook is pretty stupid.
I see logcats occasionally of it finding things.
In our 2.1 you can't even invoke it on a directory, only a file.
I gave up using it as a source for book information and do my own scanning.
I haven't looked into why it doesn't work as well as it should.
Click to expand...
Click to collapse
Can I ask how you do your own scanning? Is there a way to compile the external media db from within the nook without having to offload it and manually enter in the queries/locations of the items? I noticed there is an app in the appstore that searches for certain music files and adds them to the db, seems like something like that can be done. Also, I had some weird phenomenon, I had all the pictures deleted from the downloads directory automatically. I also read some bug reports where occasionally directories with .nomedia in them had images disappear from the sd card. Maybe the media scanner is treating every directory like it has a .nomedia file in it. Probably on purpose since they were trying to extend battery life.
Also, speaking of the battery, I calculated that I'm now getting about 7-9 days of battery on standby/if I don't touch anything, is that normal for a brand new nook newly rooted? If I use it extensively but without games etc. the battery would last 15+ hours.
Also, since you're here and the person to ask, any news on getting audio? Do you forsee in the future it will be as easy as buying a dongle and installing an app?

ERROR: “Documents.library-Ms Is No Longer Working”

Hi All, I seem to have a repeating error where my Windows 8 Pro Libraries keep breaking. The error message is "<libraryname>.library-ms" is no longer working. Fixing the error is well documented, here for example: http://www.winhelponline.com/blog/fix-error-library-ms-is-no-longer-working-windows-7/
My problem is that it keeps happening, and it's happening the day after I fix it with the above solution. Plus it's happening for all 4 libraries (music, documents, videos, pictures). So it's a bit of a hassle.
To be clear, I always add my Windows Home Server 2011 folders to the libraries, as that's where my files are stored. I am wondering weather adding a network location is causing the repetition of this error. Has anyone else experienced this? To note, the files on my WHS 2011 server are not mapped to a drive on my Windows 8 Pro PC, and furthermore I have not added the WHS 2011 to the Homegroup - I prefer to keep things basic, but obviously will try something if it might help.
Also, I was running Windows 7 in the exact same configuration for over a year and this problem never happened. So it's definitely Windows 8, I'm just not sure if it's Windows 8 plus WHS 2011 not playing nicely. Any help appreciated.
>I always add my Windows Home Server 2011 folders to the libraries, as that's where my files are stored. I am wondering weather adding a network location is causing the repetition of this error.
Then you should find out. Replicate the WHS content on local storage and use that vs WHS for a few days to see what happens. The mantra of troubleshooting is to minimize your config until you have a known-good setup, then add new stuff one-by-one until you hit the bug. Then (hopefully) you'd have narrow down the culprit.
It's a good thing the corruption happens quickly, as ascertaining cause should be easy. The worst are the intermittent ones that occur over weeks or months.
Assuming there's no permanent fix, a workaround is to write a script for the delete/add fix mentioned. Then at least the hassle is limited to a single click per day.
Just to follow up on this. Thanks for the suggestion, I did try and reset the library's without adding the Server locations. All was fine for a bit, but then the same corruption happened and and the links to the libraries corrupted again. Not sure why. As you can see in the attached, all the libraries except the Videos one is now corrupted Seems like no one else is having this issue though (on XDA anyway).
I've experienced it myself, actually, on the machine where I moved my Documents, Pictures, Videos, Music, etc. folders out of %USERPROFILE% and onto my data drive (as in, D:\Music) then changed the library links. I just added actual links and stopped bothering with the libraries; I pretty much only use one folder for each of those content types anyhow.
Suggest reviewing your search hits more thoroughly for underlying cause(s) and not only the fix.
http://google.com/search?q="music.library-ms+is+no+longer+working" nets
http://answers.microsoft.com/en-us/...89?msgId=a51a4bb9-5c62-4881-bfa2-fa8e56fce092
suggests possible user account corruption.
http://all4naija.blogspot.com/2012/06/musiclibrary-ms-is-no-longer-working.html
"The cause of the problem is not far fetched. It could have been a program one installed previously. It could as well have been shutting down a program using the folder without following appropriate means. Like powering of Windows when a program making use of any of the Library folder is working. For example, when converting video files and shutting the computer off without finishing with the converting files."
http://www.lockergnome.com/windows/...y-ms-is-no-longer-working-error-in-windows-7/
"Windows 7 introduced libraries as a way to allow users to easily access folders containing certain data from all over their file structure without having to keep them in a specific documents directory within their user profile. The library itself can be accessed and controlled by third-party programs using an API. Unfortunately, that opens the library structure up to occasional crashes and other bugs."
Etc.
If searches don't help, minimize to a known-good setup: clean reinstall, install drivers (and nothing else), create your libraries, and run this minimal setup for a few days. If problem persists, then hardware could be the cause, and you'd need to minimize hardware config. More likely, problem disappears; add your programs back in small batches to ferret out the cause.
From the frequency of search hits, it does appear WMP libraries are susceptible to corruption. The ultimate workaround is to use a 3rd-party media manager as replacement.
BTW, I assume this isn't a hacktivated Win8, ie no system files were modded to bypass activation. If the latter, replace it. An upgrade install can also be problematic, and a clean install is suggested.

[Q] Various Issues

Just got an ATT Galaxy S5
64Gb memory card
First Issue is every time I plug it into my computer I have to switch back and forth between media nad camera otherwise the folder option shows up under my computer but when opened it lists zero items. Minor Annoyance.
Second, I spent hours copying music to my external SD card, and they are all there then as soon as I unplug it, ES file explorer says all the folders are empty and the songs playerpro finds says they arent supported even tho these are the same songs and same apps on my previous galaxy s3.
Any Ideas?
I finally deleted all the music and copied one artist.
Half of the songs showed up as unknown artist like none if the id tags were copied and the 3 songs that played were extremely distorted.
When I try to delete the now empty folders with my computer it says the folder is write protected.
Unfortunately, you didn't give us some sample song titles or even what file type they are e.g. 24 bit, 96 Khz flac /wav /mp3 /ogg, etc. Or the folder structure on the SD card. The verbatim error message (screenshot?) from your music player or other details about your configuration e.g. which S5 model, which firmware version, etc.
You said you were using "apps", plural.. but didn't tell us what those other apps were? Does the problem persist if you use a well known player like poweramp?
Your problems could be caused by many things, but without those missing critical details all we could do is make random guesses. Could be file permission problems, outdated music app, file name irregularities, unsupported music format or numerous other things. You should post a lot more information if you hope to narrow down the cause.
.
fffft said:
Unfortunately, you didn't give us some sample song titles or even what file type they are e.g. 24 bit, 96 Khz flac /wav /mp3 /ogg, etc. Or the folder structure on the SD card. The verbatim error message (screenshot?) from your music player or other details about your configuration e.g. which S5 model, which firmware version, etc.
You said you were using "apps", plural.. but didn't tell us what those other apps were? Does the problem persist if you use a well known player like poweramp?
Your problems could be caused by many things, but without those missing critical details all we could do is make random guesses. Could be file permission problems, outdated music app, file name irregularities, unsupported music format or numerous other things. You should post a lot more information if you hope to narrow down the cause.
.
Click to expand...
Click to collapse
I have used playerpro and power amp. There are hundreds of songs of various bitrates. When I copy them to the internal storage they work fine. I tried my old SD card and they did the same thing, I have read that KitKat has SD issues and think that could be the case.
Every song Worked on my previous phone with my apps. Whats weird is at somepoint after copying the files and trying to listen to them, the folders pop up empty when checked with ES File explorer and when I try to delete the empty folder It says I cant.
I tried to use windows media player to sync to it but there wasnt an option.
All you did was reiterate your original comments, to wit, it worked before on a different phone and not now. Which isn't terribly helpful. You didn't bother to provide any detailed information or context as requested. We cannot see your phone nor are we psychic. Effective troubleshooting is looking for patterns and anomalies for which detailed information is crucial.
While one aspect of your difficulties is readily apparent, your primary complaint has myriad possible causes, which you have declined to help narrow down by providing pertinent details. An odd position when seeking help from others. Perhaps someone else cares to guess at the cause in the absence of information.
Good luck.
.
fffft said:
All you did was reiterate your original comments, to wit, it worked before on a different phone and not now. Which isn't terribly helpful. You didn't bother to provide any detailed information or context as requested. We cannot see your phone nor are we psychic. Effective troubleshooting is looking for patterns and anomalies for which detailed information is crucial.
While one aspect of your difficulties is readily apparent, your primary complaint has myriad possible causes, which you have declined to help narrow down by providing pertinent details. An odd position when seeking help from others. Perhaps someone else cares to guess at the cause in the absence of information.
Good luck.
.
Click to expand...
Click to collapse
What other information is there?
The fact that the songs and app worked before means its not them. My only reasoning is either the phone or the new SD card.
It seems that once a certain amount of data is copied to the SD card, it stops writing accurately. If I format the card and copy say 100 songs, they all work fine, then I try to copy more and either
a. they arent recognized
b. They are distorted.
c. the tags dont copy and it wont play.
d. they delete themselves.
If I reformat and copy the second set of 100 songs they work fine, but the next 100 dont.
So far, if I delete and copy a single file enough times, it will eventually work perfectly. I start with an alum and recopy the songs that dont work.
Its really slow and tedious though
More details, when the songs are distorted, it starts out like you fast forwarding and after a few seconds your in the middle of the song but the seconds still say 3 or 4 seconds in.
I tested a song and it worked perfectly, then a few minutes later it was like I just mentioned.

'Storage Access Framework' woes..

TLDR at bottom!
I am needing to finally update a specialized app to support newer frameworks. I haven't had to touch this app about 8 years or so, because it was running fine, and it did its job. Sadly, because of some of the new library requirements by Google Play, it's gotta be updated. One of these changes is handling the new Storage Access Framework / writing to storage on the device. I've read the docs that searching has pointed me, and even looked at some of the examples. Sadly, the examples seem rather limited in nature, and my app doesn't seem to fit any of the 'given' examples.
The ultimate end goal is to have the users select an output directory once. And then IN that directory, the app creates folders based on the user's project. (like, 'FrontLine', 'RearLine', 'Cement', etc..). In each of these sub-directories, then, pictures and txt files are stored. (Either downloaded via http client, or taken/generated by the user.)
I was able to implement an intent calling 'ACTION_OPEN_DOCUMENT_TREE', and I get a content URI back. However, hooking that to a Camera library (for example, the androidx.camera library) needs a File or an output stream. Trying to create an output stream then gives me an error stating that access needs to be granted using the external storage permission.
I feel liek I'm missing something 'big' and obvious to connect my user's chosen output direcory into a File or some converting that will let me mkdirs, and write out files.
TLDR; Needing user to select a base output directory, in which my app creates Project directories in it, and then allows storage of pictures or text into these directories. Tried Storage Access Framework, and despite having the user select a directory, am still getting a permission denied error when trying to create output stream.
Any pointers are more then welcome, as googling I have reached dead ends, sadly. Kinda peeved at this new 'framework' and the limited scope it seems to have. (At least, in examples..)
Thanks guys!

Categories

Resources