Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
    }

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?

like image 487
user2383054 Avatar asked Jun 21 '13 15:06

user2383054


People also ask

Can 2 apps have same package name?

No, every app should have a unique package name. If you install an app with a package name which is already used in another installed app, then it will replace it.

How do I download two apps with the same name?

Open the Settings app. Scroll down, tap Utilities, and tap Parallel Apps. You'll see a list of apps that you can make copies of—not every app is supported. Find the app you want to clone, and turn its toggle to the On position.

How can I install two apps with the same package name in Android?

You can't do this. Each Android application has a package name, which effectively defines the Java/Dalvik namespace that its classes occupy. You cannot have two packages of the same name installed because it would create overlapping namespaces, which is why it always replaces the old one when you install a new one.

Can apps have the same name Google Play?

1 Answer. Please understand that the app's package name must be globally unique in Google Play (not just unique within your enterprise or Google Play Developer account).


2 Answers

Is this possible?

Sure.

It's 'cause a "failure" of the intent

No, at least not for my definition of "failure".

or because many apps packageNames have the same name?

No.

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.

like image 182
CommonsWare Avatar answered Oct 06 '22 02:10

CommonsWare


Every application must have a uniqe package name. To quote from the API guide: "The package name serves as a unique identifier for the application" and "Once you publish your application, you cannot change the package name. The package name defines your application's identity, so if you change it, then it is considered to be a different application and users of the previous version cannot update to the new version."

Note that having multiple ACTION_MAIN entries in a single manifest is perfectly valid as they represent alternative entry points into the application. See this question for more information.

like image 21
Phil Haigh Avatar answered Oct 06 '22 04:10

Phil Haigh