Marco,
This works for me but only if I define it in the manifest. Why doesn't it
work when I dynamically register the broadcast receiver?
Thanks,
Jeff
On Monday, June 15, 2009 10:09:22 AM UTC-7, Marco Nelissen wrote:
>
> You need to add:
> filter.addDataScheme("file");
>
> On Mon, Jun 15, 2009 at 10:01 AM, jonathan <[email protected]<javascript:>
> > wrote:
>
>>
>> I tried doing this dynamically in onCreate of my activity class.
>> SDCardBroadcastReceiver myReceiver = new SDCardBroadcastReceiver();
>> IntentFilter filter = new IntentFilter
>> (Intent.ACTION_MEDIA_MOUNTED);
>> filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
>> registerReceiver(myReceiver, filter);
>> but still nothing is received in my SDCardBroadcastReceiver..
>>
>> On Jun 15, 12:25 am, Jeff Sharkey <[email protected]> wrote:
>> > You need to resolve the Java variable names to their actual String
>> > constants when inserting into XML. For example, the below Java
>> > variable resolves to the actual string
>> > "android.intent.action.MEDIA_MOUNTED" which is what you would use in
>> > the intent-filter.
>> >
>> > http://d.android.com/reference/android/content/Intent.html#ACTION_MED.
>> ..
>> >
>> > j
>> >
>> >
>> >
>> > On Sun, Jun 14, 2009 at 11:34 PM, jonathan<[email protected]> wrote:
>> >
>> > > I have created a BroadcastReceiver to detect SDCard mount and unmount
>> > > event, however, I am not able to receive any events at all:
>> > > here's the androidmanifest.xml:
>> > > <receiver android:enabled="true"
>> android:label="SDCardMountReceiver"
>> > > android:exported="true"
>> > > android:name="xxx.broadcasts.SDCardBroadcastReceiver">
>> > > <intent-filter>
>> > > <action
>> > > android:name="android.content.Intent.ACTION_MEDIA_MOUNTED"></action>
>> > > <action
>> > > android:name="android.content.Intent.ACTION_MEDIA_UNMOUNTED" />
>> >
>> > > </intent-filter>
>> > > </receiver>
>> > > SDCardMountReceiver class:
>> > > public class SDCardBroadcastReceiver extends BroadcastReceiver {
>> > > public SDCardBroadcastReceiver(){
>> > > super();
>> > > System.err.println("constructor");
>> > > }
>> >
>> > > public void onReceive(Context context, Intent intent) {
>> > > Log.d("SDCardBroadCastReceiver", "receive
>> "+intent.getAction());
>> > > System.err.println("jonathan receive
>> "+intent.getAction());
>> >
>> > > }
>> >
>> > > }
>> >
>> > --
>> > Jeff Sharkey
>> > [email protected]
>>
>>
>
--
--
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
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.