androidandroid-serviceandroid-manifest

How to disable TileService for Android 34+ but keep for previous versions?


So starting from Android 34 TileService doesn't allow to start a foreground service and use location | camera | mic anymore (though no official info about it, at least we still can use widgets and shortcuts), so it's useless right now and I want to remove it for Android 34+.

In AndroidManifest.xml I have the following:

<service
    android:name="com.example.service.StartStopRecTileService"
    android:exported="true"
    android:icon="@drawable/ic_test"
    android:label="@string/app_name"
    android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
    <intent-filter>
        <action android:name="android.service.quicksettings.action.QS_TILE" />
    </intent-filter>
</service>

How can I exclude it for Android 34+?

Update

TileService works fine for Android API 35+, and allows starting foreground services


Solution

  • Add this to your service element:

    android:enabled="@bool/api_lt_34"
    

    Define this in values/bools.xml:

        <bool name="api_lt_34">true</bool>
    

    Override it in values-v34/bools.xml:

        <bool name="api_lt_34">false</bool>