How to get Android application id?

后端 未结 13 609
失恋的感觉
失恋的感觉 2020-12-07 18:26

In Android, how do I get the application\'s id programatically (or by some other method), and how can I communicate with other applications using that id?

相关标签:
13条回答
  • 2020-12-07 18:37

    Android App ES File Explorer shows the Android package name in the User Apps section which is useful for Bitwarden. Bitwarden refers to this as "android application package ID (or package name)".

    0 讨论(0)
  • 2020-12-07 18:39

    Else you can get id of process your application runs in:

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

    0 讨论(0)
  • 2020-12-07 18:39

    The PackageInfo.sharedUserId field will show the user Id assigned in the manifest.

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

    android:sharedUserId="string"
    

    The two packages with the same sharedUserId need to have the same signature too.

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

    0 讨论(0)
  • 2020-12-07 18:40

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

    0 讨论(0)
  • 2020-12-07 18:42

    i'm not sure what "application id" you are referring to, but for a unique identifier of your application you can use:

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

    0 讨论(0)
  • 2020-12-07 18:43

    Step 1: Open the Google Play Store

    Step 2: Open any App in App Store Example: facebook

    Step 3: Click on any App and Look at the Browser link and At the End id=com.facebook.katana&hl=en will be there and this is your Apps Unique Id.

    0 讨论(0)
提交回复
热议问题