How to get android app id?

In Android, how can I get the application identifier programmatically (or by some other method) and how can I exchange data with other applications using this id?

+63
android
Aug 12 '09 at 5:45
source share
11 answers

If you are looking for the value defined by applicationId in gradle, you can simply use

 BuildConfig.APPLICATION_ID 
+83
Aug 17 '16 at 13:52
source share

If you refer to the application id with the package name , you can use the Context::getPackageName ( http: // http: //developer.android.com/reference/android/content/Context.html#getPackageName%28%29 ).

If you want to communicate with another application, there are several ways:

  • Run the action of another application and send the data in the "Add-ons" "Intent"
  • Send a broadcast with a special action / category and send data to additional functions
  • If you just need to share structured data, use a content provider.
  • If you need to run another application constantly in the background, use Server and “tie” yourself to the service.

If you can clarify your exact requirement, the community can help you.

+37
Apr 18 2018-11-11T00:
source share

I'm not sure which "application identifier" you are referring to, but for the unique identifier of your application, you can use:

getApplication (). GetPackageName () method from your current activity

+3
Aug 12 '09 at 7:29
source share

Otherwise, you can get the identifier of the process in which your application is running:

final static int android.os.Process.myPid ()
Returns the identifier of this process, which can be used with killProcess (int) and sendSignal (int, int).

+1
Apr 12 '11 at 23:45
source share

I'm not sure what the app / installation id is for, but you can view the existing features in a great article from Android developers:

Summarizing:

  • UUID.randomUUID() to create an id the first time the application starts after installation and simply retrieves subsequently
  • TelephonyManager.getDeviceId() for the actual device ID
  • Settings.Secure.ANDROID_ID on relatively modern devices
+1
Apr 17 '11 at 18:01
source share

The PackageInfo.sharedUserId field will display the user ID assigned in the manifest.

If you want two applications to have the same user ID so that they can see each other’s data and run in the same process, then assign them the same user ID in the manifest:

 android:sharedUserId="string" 

Two packages with the same sharedUserId must also have the same signature.

I would also recommend reading here for a push in the right direction.

0
Aug 12 '09 at 23:45
source share

If the whole purpose is to transfer data with some other application, use the Intent sendBroadcast methods.

0
Apr 12 '11 at 19:39
source share

If you use the new build system ** Gradle, then getPackageName will strangely return the application identifier, not the package name. Therefore, MasterGaurav's answer is correct, but it does not need to start c ++

If you refer to the package name by application ID ...

Read more about the differences here .

** not so new at the moment

++ I understand that his answer got great meaning in 2011

0
Jul 07 '16 at 21:49
source share

The Android App ES File Explorer displays the name of the Android package in the "Custom Applications" section, which is useful for Bitwarden. Bitwarden calls this the "Android app package identifier (or package name)."

0
May 18 '18 at 19:53
source share

To track installations, you can, for example, use the UUID as an identifier and simply create a new one the first time you launch the application after installation. Here is a sketch of a class named "Installation" with one static Installation.id method (Context Context). You could imagine writing more installation-specific data to the INSTALLATION file.

 public class Installation { private static String sID = null; private static final String INSTALLATION = "INSTALLATION"; public synchronized static String id(Context context) { if (sID == null) { File installation = new File(context.getFilesDir(), INSTALLATION); try { if (!installation.exists()) writeInstallationFile(installation); sID = readInstallationFile(installation); } catch (Exception e) { throw new RuntimeException(e); } } return sID; } private static String readInstallationFile(File installation) throws IOException { RandomAccessFile f = new RandomAccessFile(installation, "r"); byte[] bytes = new byte[(int) f.length()]; f.readFully(bytes); f.close(); return new String(bytes); } private static void writeInstallationFile(File installation) throws IOException { FileOutputStream out = new FileOutputStream(installation); String id = UUID.randomUUID().toString(); out.write(id.getBytes()); out.close(); } 

}

You can see more at https://github.com/MShoaibAkram/Android-Unique-Application-ID

0
Nov 06 '18 at 9:12
source share

Step 1. Open the Google Play Store.

Step 2: Open any application on the App Store Example: facebook

Step 3: Click on any application and look at the "Browser" link, and id = com.facebook.katana & hl = en will appear at the end, and this is your unique application identifier.

0
Dec 18 '18 at 5:43
source share



All Articles