Closed GoogleCodeExporter closed 9 years ago
Hi, we don't indeed call this function, but we do something that's supposed to
be similar:
https://github.com/nguillaumin/osmtracker-android/blob/1e404a41ae241b02603643ddf
bf11230cddab305/src/me/guillaumin/android/osmtracker/gpx/ExportTrackTask.java#L2
46
As far as I know it has been working well so far, at least on official Android
devices. Could this be something specific to CyanogenMod?
Original comment by nicolas@guillaumin.me
on 19 Feb 2015 at 8:53
Taking a brief look at the code, I see you trigger a media scan only for the
GPX file, not for the media files. The way you do it is similar and apparently
works on CM, and this also explains why I am seeing the GPX file but not the
media files.
I haven't looked into the API calls in detail, but if the API supports scanning
of entire directories rather than single files, that would be an option.
Original comment by mich...@vonglasow.com
on 19 Feb 2015 at 5:29
Ah I see, fair enough. I think triggering an intent on
FileSystemUtils.copyFile() would do the trick:
https://github.com/nguillaumin/osmtracker-android/blob/master/src/me/guillaumin/
android/osmtracker/util/FileSystemUtils.java#L29
You seem to be on top of things, how about a pull request for this one? :)
Original comment by nicolas@guillaumin.me
on 20 Feb 2015 at 8:02
OK, just forked the project, I'll let you know when I have something.
Original comment by mich...@vonglasow.com
on 23 Feb 2015 at 10:22
Just issued pull request #44.
I implemented this a bit differently from how you suggested it: Apparently, as
of Android 4.4, there is no longer a way to trigger a scan of an entire
directory (source: http://stackoverflow.com/a/25086535/2703209).
However, there is a way to pass an array of files to scan – if you use the
MediaScannerConnection call. This is what I did instead of the intent. I'm not
sure about performance impact, but I think it's better to pass the entire list
of files to be scanned in one go rather than trigger a separate scan for each
file. In the worst of all cases, it'll do neither harm nor good.
Little side effect: when exporting to a non-empty folder, existing files in
that folder will get scanned as well – don't think that's an issue, though.
Ran a brief trial and all files (GPX and voice notes) were visible via MTP
instantly.
Original comment by mich...@vonglasow.com
on 25 Feb 2015 at 10:48
As per your suggestions regarding my pull request, I tried to add a media
scanner call to copyFile(). However, this requires a Context (apparently on
Android I can't even scratch my back without a Context), and I have no idea how
I can get a Conext inside copyFile() other than by adding a context argument to
every method the call hierarchy.
Any other ideas?
Original comment by mich...@vonglasow.com
on 10 Mar 2015 at 10:37
Ah, good point, I haven't thought of that. Well I guess then doing it on the
GPX export task is probably good enough... If you re-open your request I'll
merge it, thanks!
Original comment by nicolas@guillaumin.me
on 11 Mar 2015 at 8:24
Thanks, I merged your code so it'll be available in the next release.
Original comment by nicolas@guillaumin.me
on 18 Mar 2015 at 10:35
Original issue reported on code.google.com by
mich...@vonglasow.com
on 18 Feb 2015 at 6:03