Oh, yeah, something like ACTION_MEDIA_UPDATED would probably be safer. Regardless, I'll stick to creating and connecting to an instance of MediaScannerConnection (probably do something smart like have a member instance instead of instantiating on demand, etc...).
On Jul 6, 9:56 am, Mark Murphy <[email protected]> wrote: > 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 <[email protected]> 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 <[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 > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://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 [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

