Tuesday, January 29, 2013

Android notification manifest configuration

Recently I had to add a notification to an existing Android 2.3.3 project. I followed the nice tutorial from mobiForge but was unable to get my notification to work properly. It would display in the notification bar but when I clicked on the notification nothing happened.

The cause of my problem turned out to be a missing intent-filter definition in my AndroidManifest.xml file. This is essential: the Activity to be launched by the notification must contain an intent-filter with action and category property settings.

Here is the AndroidManifest entry from the mobiForge tutorial for the activity (AlarmDetails) that is launched by the notification.  If the intent-filter entry is missing, AlarmDetails does not start when the notification is clicked.

<activity android:name=".AlarmDetails" android:exported="false" 

    android:label="Details of the alarm">

    <intent-filter>

        <action android:name="net.learn2develop.AlarmDetails"/>

        <category android:name="android.intent.category.DEFAULT"/> 

    </intent-filter>

</activity>


No comments:

Post a Comment