Reputation: 551
I'm trying to add a new action to the MainActivity intent-filter in the Manifest, like this:
<activity
android:name="com.packagename.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
<action android:name="com.packagename.SET_ALARM" />
</intent-filter>
</activity>
But this results in the console giving the message "No Launcher activity found" when I try to reinstall the app, even though both MAIN- and LAUNCHER-actions are included. Any ideas?
Upvotes: 1
Views: 167
Reputation: 1006724
It is unlikely that this <intent-filter>
is what you want. This will respond to either MAIN
or SET_ALARM
, with the LAUNCHER
category. IOW, to use SET_ALARM
, you would have to use:
new Intent("com.packagename.SET_ALARM").addCategory(Intent.CATEGORY_LAUNCHER);
It is unlikely that any third-party app would ever use such an Intent
. And if this is for your own app, please use an explicit Intent
(e.g., new Intent(this, MainActivity.class)
) and get rid of SET_ALARM
entirely. Only add custom actions when you want third-party apps to be able to reference your component (and then, only if you are not supplying them with a PendingIntent
to work with).
If you really do want that SET_ALARM
to be used by third-party applications, you probably want:
<activity
android:name="com.packagename.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="com.packagename.SET_ALARM" />
</intent-filter>
</activity>
All that being said, I am not quite certain why Eclipse was unhappy.
Upvotes: 1