Search code examples
androidandroid-intenttile-service

Launch an activity from TileService for Android 14 is not allowed


I have a simple TileService and try to launch an activity by click on the tile. It is works on Android 13 and low but in Android 14 I get an exception:

startActivityAndCollapse: Starting activity from TileService using an Intent is not allowed.

How to fix it?


Solution

  • Here is the source code of TileService.java. And here is the documentation of startActivityAndCollapse(Intent intent).

    Both say you have to use startActivityAndCollapse(PendingIntent) because startActivityAndCollapse(Intent intent) is deprecated.

    You must be using startActivityAndCollapse(Intent intent) at the moment because you are getting this error. Use the other one instead.