I can find the way to setup Bound Services in android AIP Guides!
This demo allows any app to bind to it.But what I want is only my apk can communicate with the service I code.Is there any way to do it? How to? Thanks!
I can find the way to setup Bound Services in android AIP Guides!
This demo allows any app to bind to it.But what I want is only my apk can communicate with the service I code.Is there any way to do it? How to? Thanks!
Services are not exported by default, meaning they can only be called/bound by your application. Unless you add android:exported="true"
to your service's manifest entry, only your app will be able to bind to the service.
Service.onBind()
receives intent that was used to bind to your service. One approach is to add an permission extra to the aforementioned intent, check for its value in Service.onBind()
, and deny any bind requests in case of invalid permission value.