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. Forward porting USB OTG capability on Dell Streak

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi there,


I hope this is the correct list for my question, if not please advise
which list would be better suited.


Some people found out that the Dell Streak supports USB OTG.

http://www.streaksmart.com/2010/09/dell-streak-supports-usb-host-otg.html

however this is only true for the Eclair version. This capability was
apparently removed from the Froyo version for unknown reasons.

I would like to be able to use this on Froyo.

I've looked at the kernel sources (disclaimer: I am not a kernel
hacker) made available be Dell at

http://opensource.dell.com/releases/streak/


It appears to me that the modifications that led to the loss of
functionality are in arch/arm/mach-msm/board-qsd8x50_austin.c

What I would like to do is to port the USB OTG related code from
Eclair to Froyo.

This is difficult since:

1) I am no kernel hacker (I've tried copying some of the code
differences, but while the kernel compiled it didn't boot)

2) The USB layer seems to have somewhat changed between the kernel
versions that served as bases for both Dell tarballs. Apparently,
2.6.29 served as the base for Eclair and 2.6.32 as the base for the
Froyo vesion. In addition, I've read that the code for the Dell
kernels was lifted from different kernel versions, so the drivers
might be again from different versions.


Can I get some advice on how to proceed best?

(besides downgrading to Eclair, of course ;)

Cheers,
        Gerhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk1XGOQACgkQfg6TFvELooQpiACfaYeI1QVtudI6a0BdB0Rq0Qsc
izgAn2PiKWeFb5izrIIG3Wn9K5r0QqWZ
=2+w+
-----END PGP SIGNATURE-----

-- 

2. Call AnotherActivity

hi,i want to call another activity from current activity.
in AnotherActivity there must be a popup message which is shown after
completing tasks from 1st Activity.
so,please tell me how can i call another activity from current after
completing the progress bar....tell me.

-- 

3. How to detect walking

4. ProgressDialog Theme - TextColor or Background but not both

5. Orientation change problem.

6. Out of memory - despite being way under 16mb

7. Content-based SMS filtering