Oh, that's really not a good idea. I'm surprised the OS even lets you
fake that event.

On Wed, Jul 6, 2011 at 9:54 AM, Ab <abe.oppenh...@gmail.com> wrote:
> This also works:
>
> sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
> Uri.parse("file://" + Environment.getExternalStorageDirectory())));
>
> Though this doesn't:
>
> sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
> Uri.parse("file://" + path)));
>
>
> On Jul 6, 9:49 am, Ab <abe.oppenh...@gmail.com> wrote:
>> Thanks, this worked!  I used the below code, is this a smart usage? if
>> not, could you recommend a better strategy?  (I'd like it to be
>> compatible with api version 7 and above)
>>
>> //called after writing file, from my activity
>> if(Build.VERSION.SDK_INT >= 11)
>> {
>>    new SingleMediaScanner(this, path);
>>
>> }
>>
>> private class SingleMediaScanner implements
>> MediaScannerConnectionClient
>> {
>>         private MediaScannerConnection mMs;
>>         private String path;
>>
>>         SingleMediaScanner(Context context, String f)
>>         {
>>             mPath = f;
>>             mMs = new MediaScannerConnection(context, this);
>>             mMs.connect();
>>         }
>>
>>         @Override
>>         public void onMediaScannerConnected()
>>         {
>>             mMs.scanFile(mFile, null);
>>         }
>>
>>         @Override
>>         public void onScanCompleted(String path, Uri uri)
>>         {
>>             mMs.disconnect();
>>         }
>>
>>
>>
>>
>>
>>
>>
>> }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to