Capturing Intent.ACTION_MEDIA_SCANNER_FINISHED

by Julius Spencer » Thu, 16 Dec 2010 08:17:57 GMT


Sponsored Links
 Hi,

I have set up a BroadcastReceiver to capture:
Intent.ACTION_MEDIA_SCANNER_FINISHED
or:
"android.intent.action.MEDIA_SCANNER_FINISHED"

and I'm not able to capture the Intent.

I have tried using the Manifest as well as programmatically, without any luck:

                <receiver android:name=".MediaScannerFinishedReceiver">
                                <intent-filter>
                                                <action 
android:name="android.intent.action.MEDIA_SCANNER_FINISHED"/>
                                </intent-filter>
                </receiver>

or:

        public void registerMediaScannerListener() {
                if (mMediaScannerReceiver == null) {
                        mMediaScannerReceiver = new BroadcastReceiver() {
                                @Override
                                public void onReceive(Context context, Intent 
intent) {
                                        String action = intent.getAction();
                                        if 
(action.equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) {
                                                System.out.println("I'm here!");
                                        }
                                }
                        };
                        IntentFilter iFilter = new IntentFilter();
                        iFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
                        registerReceiver(mMediaScannerReceiver, iFilter);
                }
        }


Has anyone tried this - is there a permission or something I need to capture 
this?

Thank you for any help!

Regards,
Julius.


Regards,
Julius Spencer.

jul...@msa.co.nz
Ph: 0064 9 307 1089
Fax: 0064 9 307 5281
Mobile: 0064 21 72 5559

-- 



Re: Capturing Intent.ACTION_MEDIA_SCANNER_FINISHED

by Mark Murphy » Thu, 16 Dec 2010 08:40:43 GMT


 If the source code is any indicator, you need:

intentFilter.addDataScheme("file");

or the <data> equivalent in addition to what you have there. For example:

IntentFilter intentFilter =
                new IntentFilter(Intent.ACTION_MEDIA_SCANNER_FINISHED);
intentFilter.addDataScheme("file");
registerReceiver(mReceiver, intentFilter);






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

_The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
Available!

-- 


Sponsored Links


Re: Capturing Intent.ACTION_MEDIA_SCANNER_FINISHED

by Julius Spencer » Thu, 16 Dec 2010 08:47:13 GMT


 That was it; thank you again Mark.

Do you know why it might not work in the manifest in this case (ie. for this 
Intent)?

Regards,
Julius.







-- 



Re: Capturing Intent.ACTION_MEDIA_SCANNER_FINISHED

by Mark Murphy » Thu, 16 Dec 2010 19:16:53 GMT


 


If you have not tried the corresponding <data> element, try that.

Otherwise, it is possible that this, like ACTION_BATTERY_CHANGED, is
one that only works for registerReceiver(). I never tracked down where
the Intent is being broadcast, but you might poke at Google Code
Search to try to find that, which may give you more clues.

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

_The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
Available!

-- 



Re: Capturing Intent.ACTION_MEDIA_SCANNER_FINISHED

by julius » Sun, 23 Jan 2011 07:35:51 GMT


 





Hi,

This was the data element missing - thank you for pointing me in the
right direction!

Regards,
Julius.

-- 



Other Threads

1. Does SoftReference calls .recyle() on a Bitmap ?

Hi,

If I store bitmaps in a hashmap using SoftReference, will
SoftReference call .recycle() on the Bitmap ? And if it doesn't then
what would be a way to clear the bitmap properly from memory under the
given situation ?

thanks

-- 

2. is there any htc & mototola specific emulator to test apps?

Hello

We test our apps on usual emulator & samsung galaxy 3.
What we have observed that - our apps work fine on both of these. But
got review from some users that the apps don't work on HTC evo/desire
& in some cases Droid X.

Question -
1. If app works perfectly on one phone, why does it not work on other
having same OS version?
2. Is there any emulator to test apps specifically for HTC & Motorola.
So that we can ensure before launching that the app works well on
those phones.

Regads
Manas
http://dexterltd.com

-- 

3. Making my app a library, resource problems

4. uninstall TTS data from Android >= 1.6 ?

5. zoom and drag code registering but not actually working...

6. yahoo local search xml reply in android

7. Creating a neon scroll animation