1背景最近对我的应用做了一些小的改动,准备上架 Google Play. 本以为小事一桩,没想到要做非常多的改动。其中一个改动是谷歌要求 billing 库升级到 4.0 及以上版本。此外,另一个比较大的改动是要求升级目标版本到 31.我之前从 29 升级到 30 那次改动已经非常大了。这次应该不会太多改动,没想到总归还是 too young too simple, sometimes naive. 升级目标版本到 31 也不是那么简单。下面是谷歌官方提供的两个文章,分别详细列举了升级到版本的变更以及升级到 Android 12 的详细的变更:
Flag indicating that the created PendingIntent should be immutable. This means that the additional intent argument passed to the send methods to fill in unpopulated properties of this intent will be ignored. FLAG_IMMUTABLE only limits the ability to alter the semantics of the intent that is sent by send by the invoker of send. The creator of the PendingIntent can always update the PendingIntent itself via FLAG_UPDATE_CURRENT.
val views = RemoteViews(context.packageName, R.layout.layout_appwidget_note_list) val i = Intent(context, MainActivity::class.java) i.action = ACTION_APPWIDGET_NOTE_CLICK val pi = PendingIntent.getActivity(context, 0, i, FLAG_CANCEL_CURRENT_MUTABLE) views.setPendingIntentTemplate(R.id.lv, pi)