2015-04-15 6 views
0

Проблема в том, что в конкретном пакете есть несколько действий, которые используют конкретное намерение, я хочу список всех этих действий.Получить список действий от ResolveInfo

Если я использую

infos.activityInfo.applicationInfo.className

это дает мне только основной вид деятельности или нуль.

Ниже приведен пример того, что я получаю:

09-11 04:46:31.628: I/User Interface(6779): name: Internet -com.android.browser.Browser 
09-11 04:46:31.628: I/User Interface(6779): name: Internet -com.android.browser.Browser 
09-11 04:46:31.628: I/User Interface(6779): name: Calendar -com.android.calendar.CalendarApplication 
09-11 04:46:31.628: I/User Interface(6779): name: Calendar Storage -null 
09-11 04:46:31.628: I/User Interface(6779): name: Calendar Storage -null 
09-11 04:46:31.638: I/User Interface(6779): name: Camera -null 
09-11 04:46:31.638: I/User Interface(6779): name: Cell Broadcast -com.android.cellbroadcastreceiver.CellBroadcastReceiverApp 
09-11 04:46:31.638: I/User Interface(6779): name: Contacts -com.android.contacts.ContactsApplication 
09-11 04:46:31.638: I/User Interface(6779): name: Contacts -com.android.contacts.ContactsApplication 
09-11 04:46:31.638: I/User Interface(6779): name: Contacts -com.android.contacts.ContactsApplication 
09-11 04:46:31.638: I/User Interface(6779): name: Contacts -com.android.contacts.ContactsApplication 
09-11 04:46:31.638: I/User Interface(6779): name: Contacts -com.android.contacts.ContactsApplication 
09-11 04:46:31.638: I/User Interface(6779): name: Contacts -com.android.contacts.ContactsApplication 
09-11 04:46:31.648: I/User Interface(6779): name: EasyHome -com.lge.easyhome.LauncherApplication 
09-11 04:46:31.658: I/User Interface(6779): name: File Manager -null 
09-11 04:46:31.658: I/User Interface(6779): name: Gallery -com.android.gallery3d.app.GalleryAppImpl 
09-11 04:46:31.658: I/User Interface(6779): name: Gallery -com.android.gallery3d.app.GalleryAppImpl 
09-11 04:46:31.658: I/User Interface(6779): name: Home -com.lge.launcher2.LauncherApplication 

Вы можете видеть, что несколько раз имя приложения скрипящий, но активность такой же. Что это значит? Правильно ли я полагаю, что это намерение используется в нескольких действиях? Если да, то есть ли способ получить все эти действия?

Вот код, который я написал.

Intent mainIntent = new Intent(); 
    mainIntent.setAction(Intent.ACTION_MAIN);   
    mainIntent.setType("text/plain"); 
    List<ResolveInfo> pkgAppsList = getApplicationContext().getPackageManager().queryIntentActivities(mainIntent, 0); 

    int size = pkgAppsList.size();   
    Log.i(TAG, "Size: " + size); 
    for(ResolveInfo info : pkgAppsList){ 

     String name = info.activityInfo.applicationInfo.loadLabel(getPackageManager()).toString(); 

     Log.i(TAG, "name: " + name + " -" + info.activityInfo.applicationInfo.className); 
    } 

ответ

0
> Am I correct in thinking that this intent is being 
    > used in multiple activities? 

намерение может матч несколько мероприятий. Ваш пример должен перечислить все

основной-активности с ContentFilter ContentType «текст/простой»

Для рабочего примера см метод checkAndShowMatchingActivites() в intent-intercept.. Explode.java

+0

Infos и информация была опечатка. Исправлено. Сожалею. – Ekta

Смежные вопросы