1.先是bean的问题:
这里喜欢用快捷方法,alt+insert 快速生成bean,遇到一些集合bean默认会生成集成的方式,比如:
class RegionalProtectionBean : ArrayList<RegionalProtectionBeanItem>()
在后面的版本不可用了,因为没有size方法了导致最后改了很多。
2.pendingintent 问题:
java.lang.IllegalArgumentException: com.example.imdemo: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent
PendingIntent pendingIntent;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
pendingIntent = PendingIntent.getActivity(this, 123, intent, PendingIntent.FLAG_IMMUTABLE);
} else {
pendingIntent = PendingIntent.getActivity(this, 123, intent, PendingIntent.FLAG_ONE_SHOT);
}
这个方法没有解决我的问题。最后还是修改了runtime的版本号解决问题。
dependencies {
// For Java
implementation 'androidx.work:work-runtime:2.7.1'
// For Kotlin
implementation 'androidx.work:work-runtime-ktx:2.7.1'
}
原来版本是2.5.4 升级到2.7.1才成功,具体的原因不知道,后期再补回。