Java 从ResolveInfo获取活动列表
问题是,在一个特定的包中,有几个活动使用特定的意图,我想要所有这些活动的列表 如果我使用Java 从ResolveInfo获取活动列表,java,android,android-intent,Java,Android,Android Intent,问题是,在一个特定的包中,有几个活动使用特定的意图,我想要所有这些活动的列表 如果我使用 infos.activityInfo.applicationInfo.className 它只给我主活动或null 下面是我得到的示例: 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
infos.activityInfo.applicationInfo.className
它只给我主活动或null
下面是我得到的示例:
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);
}
Intent maintent=newintent();
mainIntent.setAction(Intent.ACTION_MAIN);
mainIntent.setType(“文本/普通”);
List pkgAppsList=getApplicationContext().getPackageManager().QueryInputActivities(mainIntent,0);
int size=pkgAppsList.size();
Log.i(标签,“尺寸:”+尺寸);
for(ResolveInfo:pkgAppsList){
字符串名称=info.activityInfo.applicationInfo.loadLabel(getPackageManager()).toString();
Log.i(标记,“name:+name+”-“+info.activityInfo.applicationInfo.className”);
}
一个意图可以匹配多个活动。您的示例应该列出所有
具有contentfilter contenttype“text/plain”的主活动
有关工作示例,请参见infos中的方法checkAndShowMatchingActivites(),信息是一个输入错误。更正了。很抱歉
> Am I correct in thinking that this intent is being
> used in multiple activities?