views:

294

answers:

0

Hello, I have a view as a main screen of the application which contains the available application's actions as icon+text pairs ( desktop like).

I want to find out programatically what are the activities defined ONLY in my AndroidManifest.xml

Suppose I have : < activity android:name="example.mainActivity" android:label="mainActivity">
< intent-filter>
< action android:name="android.intent.action.MAIN" />
< category android:name="android.intent.category.LAUNCHER" />
< /intent-filter>
< /activity>
< activity android:name="example.activity1" android:label="Activity1">
< intent-filter>
< action android:name="android.intent.action.VIEW" />
< category android:name="example.custom.ACTIVITY" />
< /intent-filter>
< /activity>
< activity android:name="example.activity2" android:label="Activity2">
< intent-filter>
< action android:name="android.intent.action.VIEW" />
< category android:name="example.custom.ACTIVITY" />
< /intent-filter>
< /activity>

I want that in the mainActivity to dinamically read Activity1 and Activity2 because when i add Activity3 for example it will be automatically read.

Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("example.custom.ACTIVITY"); List resolves = getPackageManager().queryIntentActivities(intent, 0);

In the resolves list i expect to have the two defined activities so i can get their label and image and create the icon for the desktop

I thought that this could be done by defining a custom category, example.custom.ACTIVITY, and in the mainActivity use the packageManager.queryIntentActivities(Intent intent, int flags) but it doesn't seem to be working.

I really would like to code it to dinamically discover the installed activities in my application. Do you have any ideas on how to do this? Thank you