How to get application package name or UID which is trying to bind my service from onBind function?

前端 未结 6 1922
说谎
说谎 2020-12-03 03:17

I have a service in an application, and I can reach this service from different applications. And when applications are tried to bind this service I want to know which appli

6条回答
  •  温柔的废话
    2020-12-03 03:58

    You can't do this.

    onBind() is called from the Android "lifecycle manager" (making up a helpful name), and will only be called once for each Intent (so it can learn which Binder should be returned for that Intent).

    The calls to your service then come in over that Binder, and you can do Binder.getCallingUid() in any one of those methods.

提交回复
热议问题