How to get Android application id?

后端 未结 13 611
失恋的感觉
失恋的感觉 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:57

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

    In case you wish to communicate with other application, there are multiple ways:

    1. Start an activity of another application and send data in the "Extras" of the "Intent"
    2. Send a broadcast with specific action/category and send data in the extras
    3. If you just need to share structured data, use content provider
    4. If the other application needs to continuously run in the background, use Server and "bind" yourself to the service.

    If you can elaborate your exact requirement, the community will be able to help you better.

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