There is a service project without activity . The service will launch another application.

In the book of this example it is written: We register the service in the manifest and add an IntentFilter with action = "testservice" .

Where to add a filter if there is no activity section in manifest ?

Manifest:

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.denis.testselfservice"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <service android:name=".MyService" android:enabled="true" android:exported="true"></service> </application> 

  • 2
    100% not sure, but not too long ago I also tried to write an application without activating and ran into a problem that the intent filters since some version of the android (5th or something) did not work until the user sees at least once any activations of the same application. This is such protection from hidden malicious applications. Although perhaps this was only for certain filters, not all. In general, be prepared that you still have to activate at least one. - xkor

1 answer 1

 <service android:name=".MyService" android:enabled="true" android:exported="true"> <intent-filter> //Вот сюда </intent-filter> </service> 

Sobsna, and what have the activism?)

  • Thanks Android Android! I didn’t work with services and didn’t know that filters can be installed not only in activit. - Kamenev_D
  • @Kamenev_D yes not) - Android Android
  • I understand in KitKat START_STICKY does not work? Or doing something wrong? I kill the process in ADM, but it does not start anymore. - Kamenev_D
  • But on what basis should it start? - Android Android
  • If you believe the manual, then after the process is completed with the START_STICKY flag, the system should start it again. But does not start. - Kamenev_D