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. Camera Preview

Camera Preview sample code in here:
http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.html

My questions are:
1. There's an error in the program, in the try{} catch{} part in
surfaceCreated(). Any suggestions on how to solve this problem?
2. In the top part of the html page written "The file containing the
source code shown below is located in the corresponding directory in
<sdk>/platforms/android-<version>/samples/...". But I can not find the
sample code in that directory. Is the information wrong or my system
is incomplete?
3. What do I get (see) when the program run normally?

Thanks for the answer.

--~--~---------~--~----~------------~-------~--~----~

2. SlidingDrawer to go full screen

How do I get the sliding drawer to open over the existing layout.  I'm
having a hard time finding an example and having no luck figuring it
out on my own.

-- 

3. call Activity from the BroadcastReceiver.

4. Problem in integration of Facebook with android app

5. youtube videos using google api client library

6. Network I/O in background thread

7. NFC Concerns