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?
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)
becausestartActivityAndCollapse(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.