两个不同的应用程序可以具有相同的packageName吗? [英] Can two different apps have the same packageName?
问题描述
我有以下代码来获取系统上所有应用程序的列表:
I have this code to get a list of all apps on system:
PackageManager pm = getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN);
List<ResolveInfo> installedApps = pm.queryIntentActivities( mainIntent, 0);
for(ResolveInfo elem : installedApps) {
String PackageName = elem.activityInfo.applicationInfo.packageName;
Log.i("TAG",PackageName);
}
但是installedApps中的结果显示了许多重复的PackageName. 这可能吗?是因为意图失败"还是因为许多应用程序的packageNames具有相同的名称?
But the result in installedApps shows many repeated PackageNames. Is this possible? It's 'cause a "failure" of the intent or because many apps packageNames have the same name?
推荐答案
这可能吗?
Is this possible?
好的.
这是由于意图的失败"
It's 'cause a "failure" of the intent
不,至少不是因为我对失败"的定义.
No, at least not for my definition of "failure".
还是因为许多应用程序的packageNames具有相同的名称?
or because many apps packageNames have the same name?
否.
这是因为您要查询的是活动,而不是应用.一个应用程序可以具有零个,一个,两个或一百万个活动,这些活动将响应ACTION_MAIN
Intent
.
It is because you are querying for activities, not applications. An application can have zero, one, two, or a million activities that will respond to an ACTION_MAIN
Intent
.
这篇关于两个不同的应用程序可以具有相同的packageName吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!