I want to implement the service in the application.

Added in its manifest

<service android:name=".tools.services.MyService" android:enabled="true" android:exported="true"> </service> 

Highlights the word service and says that if I do not add permission, it will not work

If you want to specify the option of exported = false), you can’t. Without this, any application can use this service.

If I press Alt + Enter and add what it asks, it turns out like this

 <service android:name=".tools.services.MyService" android:enabled="true" android:exported="true" android:permission=""> </service> 

But what do you need to add to android:permission="" ?

  • 3
    Well, if you are not going to share your service, then put android:exported="false" - ermak0ff
  • @ ermak0ff and the sharer is so that third-party applications can use my service? Or for what? - Aleksey Timoshchenko
  • Yes, in this context I meant it. - ermak0ff

1 answer 1

This is your custom permission and you yourself should come up with a name if you want to request it from the application that tries to call your service. For example:

 android:permission="com.yourpackagename.service.ACCESS" 

This permission will be requested when installing that application.

Well, of course, permission is not needed if you do not want other applications to use the service. Then just specify android:exported="false" .