Reputation: 23
I'm learning to write the notification code for the first time in android and seeing errors in AndroidManifest.xml file with the activity names(as they are appearing red, I guess meaning error) hence, can't run the app.
The error is thrown in the
android:names(yes in all three of them) ,they can't , I believe fetch the information they required.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aptech.androidservice.androidnotificationexaample"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="11"
android:targetSdkVersion="19"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:allowBackup="false"
android:icon="@drawable/ic_launcher_background"
android:label="@string/app_name">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:name=".NotificationActivity"
android:label="Notification Click Action"
android:name=".SubNotificationActivity"
android:label="Sub Notification Click Action">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Upvotes: 0
Views: 205
Reputation: 1340
You are facing this issue because each activity tag can only have one name. Remember xml format is key-value, of which key is UNIQUE, so you have to write multiple tags, like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aptech.androidservice.androidnotificationexaample"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="11"
android:targetSdkVersion="19"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:allowBackup="false"
android:icon="@drawable/ic_launcher_background"
android:label="@string/app_name">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SubNotificationActivity"
android:label="Sub Notification Click Action"/>
<activity
android:name=".NotificationActivity"
android:label="Notification Click Action"/>
</application>
Upvotes: 1
Reputation: 157
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:name=".NotificationActivity"
android:label="Notification Click Action"
android:name=".SubNotificationActivity"
android:label="Sub Notification Click Action">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
That's not how you define activities in your app, each activity must have a separate activity tag.
<activity
android:name=".MainActivity"
android:label="@string/app_name"/>
<activity
android:name=".NotificationActivity"
android:label="Notification Click Action"/>
<activity android:name=".SubNotificationActivity"
android:label="Sub Notification Click Action">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 1