On Tuesday, December 22, 2015 at 12:49:55 AM UTC-8, gjs wrote:
>
> Hi,
>
> MediaScannerConnection scanFile() (& the equivalent Intent), is just a 
> request to the OS, it does provide an on completion listener to let you 
> know when it is finished the request, but that doesn't necessarily mean it 
> actually or immediately performs the 'scanning' for you request, it might 
> defer or ignore it. (Once upon a time it did scan when requested, but you'd 
> need to read recent Android OS Source code / Photos app source code to be 
> certain).
>
> Proving your own media viewer activity or using an Intent to open the 
> media file or showing the image capture briefly or as a thumbnail is 
> usually what done to provide immediate feedback.
>

My intention was to do something that would make the "Photos" app see my 
stored videos.  This (MediaScannerConnection) doesn't appear to be doing 
it, and I haven't seen any real confirmation that it's even supposed to do 
it.  What is the point of doing this?  I'm going to guess that if I just 
change the subdir name I write to to "Camera", then "Photos" will see my 
videos.
 

>
> Regards
>
>
> On Tuesday, December 22, 2015 at 5:29:36 AM UTC+11, David Karr wrote:
>>
>> On Monday, December 21, 2015 at 12:08:57 AM UTC-8, gjs wrote:
>>>
>>> Hi,
>>>
>>> If your phone is not a Google Nexus variety then that's not surprising, 
>>> but Environment.getExternalStoragePublicDirectory(Environment.
>>> DIRECTORY_DCIM) is what's recommended.
>>>
>>> In some respects it does not really matter which folder you use to store 
>>> media generated by your app (*), provided you go to the trouble of 
>>> 'cataloging' the media generated using MediaScannerConnection - 
>>> http://developer.android.com/reference/android/media/MediaScannerConnection.html#scanFile(android.content.Context,
>>>  
>>> java.lang.String[], java.lang.String[], 
>>> android.media.MediaScannerConnection.OnScanCompletedListener) then your 
>>> photos / video will quickly show up in the default 'Photos' app, without 
>>> having to wait for it to scan the device periodically to find new media 
>>> files.
>>>
>>> (*) And is some other respects it really, really does matter what folder 
>>> you use - if you don't want the media files deleted when your app in 
>>> uninstalled (!) Be very careful about what you decide, here's some 
>>> 'interesting' history - 
>>> https://groups.google.com/forum/#!topic/android-platform/14VUiIgwUjY%5B1-25%5D
>>>
>>> Regards
>>>
>>>
>> Ok, following this information and some other advice (I created a custom 
>> subdir of "DCIM" for my app), I ended up with the following:
>>
>> sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, 
>> Uri.parse("file://" + outputFilePath)));
>>
>>
>>  The problem is, it's not clear to me that this is doing anything.  After 
>> storing one of these and calling this, I exit my app and run the Photos 
>> app, and the new video is not shown there.  I've verified that the video is 
>> stored and viewable.
>>
>> On Monday, December 21, 2015 at 5:53:49 AM UTC+11, David Karr wrote:
>>>>
>>>> On Saturday, December 19, 2015 at 10:34:46 PM UTC-8, gjs wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> See http://developer.android.com/reference/android/os/Environment.html 
>>>>> it has methods to retrieve default paths of where photo, video files etc 
>>>>> are stored.
>>>>>
>>>>> The file naming convention should be easy enough to mimic, usually 
>>>>> being based on date time stamps.
>>>>>
>>>>
>>>> Thanks.  That gets pretty close.  I'm having trouble getting it to 
>>>> match what my phone is using.  For the directory expression, I'm currently 
>>>> using this:
>>>>
>>>> Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)
>>>>
>>>>
>>>> However, on my phone, the actual place where it stores pictures from 
>>>> the stock camera is in a "Camera" subdirectory.  This expression doesn't 
>>>> include that.  I could hardcode that, but doesn't feel right.  I tried 
>>>> some 
>>>> variations of this, but I never found an expression that returns "Camera" 
>>>> as the base directory name.
>>>>
>>>>>
>>>>> Regards
>>>>>
>>>>> On Sunday, December 20, 2015 at 4:58:02 AM UTC+11, David Karr wrote:
>>>>>>
>>>>>> Because I can't bring up the stock camera app with just a video 
>>>>>> record/stop button (I'm using a remote bluetooth button to start/stop 
>>>>>> recording), I've written a custom app that just displays the camera 
>>>>>> preview 
>>>>>> and a video record/stop button.
>>>>>>
>>>>>> Despite the fact that this is a custom app, as much as possible I'd 
>>>>>> like to store the videos as if they were taken with the stock app.  This 
>>>>>> at 
>>>>>> least means storing them in the same place, with a consistent naming and 
>>>>>> metadata scheme.  I might consider having custom preferences in the app, 
>>>>>> but for now I'd just like to retrieve properties that will tell me where 
>>>>>> the stock camera app will store videos, along with any other 
>>>>>> configuration 
>>>>>> that should describe how I store the videos.
>>>>>>
>>>>>> How can I get this information within my custom app?
>>>>>>
>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/8d5bc8cf-7e69-45df-ae8d-14b22bd2a112%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to