Unique ID of Android app
What is the unique id of androi开发者_StackOverflowd application? Is it package name? Can there be two applications with the same packages names on one device?
There are 2 different things: the Java package and the Android Application package. The second one needs to be Unique.
There is a good article about it here
Yes, the package name is the unique identifier for an android application in the market.
No, there can't be two apps with the same package name in the market/on the device.
I'd like to add one little clarification that wasn't mentioned here.
Although there can't be two apps with the same package name, there can be several launcher activities within one app that user can see in launcher app. For example, standard "Maps" application ("com.google.android.apps.maps" package) has several launcher activities like "Local", "Navigation", "Maps". It doesn't matter for user if these "apps" (or activities, in developer terms) are implemented in one application package or not.
Activity name ("com.google.android.maps.MapsActivity") is not unique itself too, because anyone can create an app with unique package name and an activity located in java package com.google.android.maps called MapsActivity.
Thus, if you want to find unique identifier for all these launcher activities, you should use combination of both app package name ("com.google.android.apps.maps") and activity name ("com.google.android.maps.MapsActivity").
Package name must be different, you can't upload an app with same package name like an existing one.
The unique identifier for Android apps is now the applicationId
field in the build.gradle
file. Devices will determine whether an app is an update to an existing app or a new app based on that field.
精彩评论