我正在尝试将目标版本更改为 Android 12 (S)。但我有一个错误
java.lang.IllegalArgumentException: : Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
强烈考虑使用 FLAG_IMMUTABLE,仅当某些功能依赖于 PendingIntent 是可变的时才使用 FLAG_MUTABLE,例如,如果它需要与内联回复或气泡一起使用。
产生此错误的代码是:
return regRestClient.getToken(idRef)
.onErrorResumeNext(
regRestClient.registerDevice(idRef, Build.PRODUCT, Build.MODEL)
.flatMap(response -> regRestClient.getToken(idRef))
)
.map((result) ->
new TokenResult(result.getToken())
)
.doOnError(error -> provideActivityToConsumer(activity -> onRegFailed(activity, error)))
.onErrorReturn(throwable -> new TokenResult(null));
获取设备令牌查询:
@GET("device/{deviceId}")
@Headers( {Api.HEADER, Api.AUTH})
Single<TokenResult> getToken(@Path("idd") IdRef id);
我不明白,似乎 RxJava 库或改造库有一些 PendingIntent 功能,但我不明白究竟是哪个库。
我的图书馆:
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.18'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
请帮忙!