See the details in this blog post.
I've found this through trial an error, so I hope this helps save you some time.
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.codtech.android.training.sampleintentreceiver">
- <application android:icon="@drawable/icon">
- <receiver android:name=".SampleIntentReceiver">
- <intent-filter>
- <action android:name="com.codtech.android.training.intent.SAMPLE_ACTION"/>
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.GET_CONTENT"/>
- <data android:mimeType="image/*"/>
- <category android:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- </receiver>
- </application>
- </manifest>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
Using java Syntax Highlighting
- /**
- * Copyright © 2008 Diego Torres Milano <dtmilano at gmail dot com>
- */
- package com.codtech.android.training.intentreceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.content.IntentReceiver;
- import android.util.Log;
- import android.widget.Toast;
- /**
- * @author diego
- *
- */
- public class SampleIntentReceiver extends IntentReceiver {
- private static final String TAG = "SampleIntentReceiver";
- /*
- * (non-Javadoc)
- *
- * @see android.content.IntentReceiver#onReceiveIntent(android.content.Context,
- * android.content.Intent)
- */
- @Override
- public void onReceiveIntent(Context context, Intent intent) {
- String msg = "SampleIntentReceiver:nonReceiveIntent(context="
- + context.getPackageName()
- + ", intent=[" + intent.getAction() + ", " + intent.getType()
- + ", " + intent.getData() + "])";
- Log.d(TAG, msg);
- Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
- }
- }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

