国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified

這篇具有很好參考價(jià)值的文章主要介紹了Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

最近在寫代碼時(shí)碰到如下錯(cuò)誤:

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.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

出錯(cuò)的代碼主要是在創(chuàng)建通知欄消息時(shí)拋出的,主要代碼如下:

private void createNotification() {
    Intent intent = new Intent(this, OtherActivity.class);
    // 這一行報(bào)錯(cuò)
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 123, intent, PendingIntent.FLAG_ONE_SHOT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle("測試")
            .setContentText("收到一條通知消息")
            .setContentIntent(pendingIntent)
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .setAutoCancel(true);
    Notification build = builder.build();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.createNotificationChannel(
                new NotificationChannel(NOTIFICATION_CHANNEL_ID, "測試測試", NotificationManager.IMPORTANCE_HIGH)
        );
    }
    NotificationManagerCompat.from(this).notify(notificationId++, build);
}

查了一番資料后,發(fā)現(xiàn)如下幾個(gè)修復(fù)的方法:

  1. 將項(xiàng)目的targetSdkVersion由31改為30

  2. 如果不想改targetSdkVersion,那就在在創(chuàng)建PendingIntent的時(shí)候判斷當(dāng)前系統(tǒng)版本,根據(jù)不同系統(tǒng)版本創(chuàng)建帶有不同flag的PendingIntent,具體代碼實(shí)現(xiàn)如下:

    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);
    }
    
  3. 直接在項(xiàng)目中依賴下面的庫

    dependencies {
      // For Java
      implementation 'androidx.work:work-runtime:2.7.1' 
     
      // For Kotlin
      implementation 'androidx.work:work-runtime-ktx:2.7.1'
    }
    

這里最推薦的是使用上面的方法2。文章來源地址http://www.zghlxwxcb.cn/news/detail-664833.html

到了這里,關(guān)于Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • ERROR: Could not find a version that satisfies the requirement

    ERROR: Could not find a version that satisfies the requirement

    報(bào)錯(cuò)提示: ERROR: Could not find a version that satisfies the requirement numpy (from versions: none) ERROR: No matching distribution found for numpy ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none) ERROR: No matching distribution found for cv2 [notice] A new release of pip is available: 23.0.1 - 23.1.2 [notice] T

    2024年02月14日
    瀏覽(102)
  • ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)

    ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)

    ? “當(dāng)我年輕的時(shí)候,我想變成任何一個(gè)人除了我自己。” ? ? ??作者主頁: 追光者♂?? ???????? ??個(gè)人簡介: ? ??[1] 計(jì)算機(jī)專業(yè)碩士研究生?? ? ??[2] 2023年城市之星領(lǐng)跑者TOP1(哈爾濱)?? ? ??[3] 2022年度博客之星人工智能領(lǐng)域TOP4?? ? ??[4] 阿里云社區(qū)特邀專家

    2024年02月12日
    瀏覽(91)
  • pip報(bào)錯(cuò)ERROR: Could not find a version that satisfies the requirement pandas (from versions: none)

    pip報(bào)錯(cuò)ERROR: Could not find a version that satisfies the requirement pandas (from versions: none)

    下載pandas報(bào)錯(cuò)如下: ERROR: Could not find a version that satisfies the requirement pandas (from versions: none) ERROR: No matching distribution found for pandas 解決方法: ?在語句后面加上其他源,我這里用的清華源 然后成功:! !! ?ps: 國內(nèi)常用鏡像源 清華大學(xué) :https://pypi.tuna.tsinghua.edu.cn/simple/ 阿

    2023年04月08日
    瀏覽(96)
  • AndroidStudio打包失敗Error: Google Play requires that apps target API level 31 or higher.解決辦法

    AndroidStudio打包失敗Error: Google Play requires that apps target API level 31 or higher.解決辦法

    首先找到build.gradle文件 在targetSdkVersion上面加一行注釋: 然后在Android{}塊中加入? 以下為完整代碼圖 再次打包就ok了

    2024年04月14日
    瀏覽(22)
  • 【Bug——Python】ERROR: Could not find a version that satisfies the requirement pip (from versions: none

    【Bug——Python】ERROR: Could not find a version that satisfies the requirement pip (from versions: none

    目錄 一、項(xiàng)目場景 二、問題描述 三、原因分析 三、解決方案 四、總結(jié) pip報(bào)錯(cuò) 今天在升級(jí)pip的時(shí)候發(fā)生了如下的報(bào)錯(cuò)問題: 報(bào)錯(cuò)內(nèi)容翻譯: 錯(cuò)誤:找不到滿足要求的版本pip(來自版本:none) 錯(cuò)誤:找不到與pip匹配的分發(fā) ????????我們經(jīng)常通過pip安裝東西時(shí)常常會(huì)出現(xiàn)

    2024年02月08日
    瀏覽(433)
  • 關(guān)于Could not find a version that satisfies the requirement報(bào)錯(cuò)的解決方案

    關(guān)于Could not find a version that satisfies the requirement報(bào)錯(cuò)的解決方案

    在使用python的pip命令安裝各類package時(shí),命令運(yùn)行后會(huì)分3次返回警告類信息: Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by \\\'ConnectTimeoutError(pip._vendor.requests.packages.urllib3. connection.VerifiedHTTPSConnection object at 0x00000218CA6213C8, \\\'Connection to pypi.python.org timed out

    2024年02月02日
    瀏覽(99)
  • [flutter][報(bào)錯(cuò)]One or more plugins require a higher Android SDK version.

    報(bào)文 解決 修改方案:找到本地flutter安裝目錄D:flutterflutter_windows_3.3.1-stableflutterpackagesflutter_toolsgradle,修改flutter.gradle文件內(nèi)static int compileSdkVersion = 31==》static int compileSdkVersion = 33 引用 flutter 項(xiàng)目報(bào)錯(cuò) One or more plugins require a higher Android SDK version.

    2024年02月04日
    瀏覽(16)
  • ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none) | 面試題:裝飾器

    ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none) | 面試題:裝飾器

    ? “當(dāng)我年輕的時(shí)候,我想變成任何一個(gè)人除了我自己?!?? ? ??作者主頁: 追光者♂?? ???????? ??個(gè)人簡介: ? ??[1] 計(jì)算機(jī)專業(yè)碩士研究生?? ? ??[2] 2023年城市之星領(lǐng)跑者TOP1(哈爾濱)?? ? ??[3] 2022年度博客之星人工智能領(lǐng)域TOP4?? ? ??[4] 阿里云社區(qū)特邀專家

    2024年02月06日
    瀏覽(88)
  • 安裝opencv遇到的問題ERROR: Could not find a version that satisfies the requirement opencv (from versions: n

    安裝opencv遇到的問題ERROR: Could not find a version that satisfies the requirement opencv (from versions: n

    ERROR: Could not find a version that satisfies the requirement opencv (from versions: none) ERROR: No matching distribution found for opencv解決方法 使用pip 安裝時(shí),有時(shí)會(huì)遇到網(wǎng)上慢或者撞墻的現(xiàn)象,這時(shí)我們就到這個(gè)網(wǎng)站手動(dòng)下載你需要的安裝包,手動(dòng)安裝,地址 2.找到opencv。因?yàn)槲沂褂玫氖?Python 3.8

    2024年02月13日
    瀏覽(101)
  • 服務(wù)器pip3配置requirements.txt時(shí)候could not find a version that satisfies the requirement pywin32

    服務(wù)器pip3配置requirements.txt時(shí)候could not find a version that satisfies the requirement pywin32

    服務(wù)器安裝pywin32報(bào)錯(cuò): ?這個(gè)沒解決我的問題: pycharm安裝pywin32 報(bào)錯(cuò):No matching distribution found for pywin32_棠寧的博客-CSDN博客_no matching distribution found for pywin32 然后還有人這樣: Could not find a version that satisfies the requirement win32api (from versions: ) No matching distribution found for win32api

    2024年02月05日
    瀏覽(98)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包