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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en