Upgrade to Pro — share decks privately, control downloads, hide ads and more …

compileSdkVersion33でgetSerializable/getParcelab...

napplecomputer
December 22, 2022

 compileSdkVersion33でgetSerializable/getParcelableがつらい話

napplecomputer

December 22, 2022
Tweet

More Decks by napplecomputer

Other Decks in Technology

Transcript

  1. Mobility Technologies Co., Ltd. 2 ▪ @napplecomputer ▪ ͳͬͽʔ ▪

    גࣜձࣾMobility Technologies(MoT)ॴଐ ▪ λΫγʔΞϓϦʮGOʯͷϢʔβʔΞϓϦ ▪ ࡢ೔ΧϝϥҿΈ·ͨ͠ ࣗݾ঺հ
  2. Mobility Technologies Co., Ltd. 7 ▪ Target SDK VersionΛ্͛Δ͜ͱͰڍಈͷมΘΔ෦෼ͷରԠͱಈ࡞֬ೝ ▪

    ྫ͑͹Notification Runtime Permission ▪ Compile SDK VersionΛ্͛Δ ▪ Target SDK VersionΛCompile SDK VersionΑΓߴ͘͢Δ͜ͱ͸Ͱ͖ͳ ͍ Target SDK Version 33 ରԠ
  3. Mobility Technologies Co., Ltd. 9 ▪ Compile SDK Version 33

    ରԠͱ͸ͭ·ΓAPI level 33Ͱdeprecatedʹͳͬ ͨAPIΛ࢖༻͍ͯ͠Δ෦෼Λมߋ͢Δ͜ͱ ▪ onBackPressedͷมߋͳͲ৭ʑ͋Δ ▪ ಛʹBundleͱIntentͷมߋ͕ͭΒ͍ Compile SDK Version 33 ରԠ
  4. Mobility Technologies Co., Ltd. 10 ▪ T getParcelable(String) ▪ Parcelable[]

    getParcelableArray(String) ▪ ArrayList<T> getParcelableArrayList(String) ▪ Serializable getSerializable(String) ▪ SparseArray<T> getSparseParcelableArray(String) BundleͷDeprecated in API level 33
  5. Mobility Technologies Co., Ltd. 11 ▪ T getParcelable(String) ▪ Parcelable[]

    getParcelableArray(String) ▪ ArrayList<T> getParcelableArrayList(String) ▪ Serializable getSerializable(String) ▪ SparseArray<T> getSparseParcelableArray(String) BundleͷDeprecated in API level 33
  6. Mobility Technologies Co., Ltd. 12 ▪ T getParcelable(String, Class<T>) ▪

    T[] getParcelableArray(String, Class<T>) ▪ ArrayList<T> getParcelableArrayList(String, Class<?, extends, T>) ▪ T getSerializable(String, Class<T>) ▪ SparseArray<T> getSparseParcelableArray(String, Class<?, extends, T>) BundleͷAdded in API level 33
  7. Mobility Technologies Co., Ltd. 13 ▪ Parcelable[] getParcelableArrayExtra(String) ▪ ArrayList<T>

    getParcelableArrayListExtra(String) ▪ T getParcelableExtra(String) ▪ Serializable getSerializableExtra(String) IntentͷDeprecated in API level 33
  8. Mobility Technologies Co., Ltd. 14 ▪ T[] getParcelableArrayExtra(String, Class<T>) ▪

    ArrayList<T> getParcelableArrayListExtra(String, Class<?, extends, T>) ▪ T getParcelableExtra(String, Class<T>) ▪ T getSerializableExtra(String, Class<T>) IntentͷAdded in API level 33
  9. Mobility Technologies Co., Ltd. 18 bundle.getSerializable(KEY_HOGE, HOGE::class.java) if (Build.VERSION.SDK_INT >=

    Build.VERSION_CODES.TIRAMISU) { bundle.getSerializable(KEY_HOGE, HOGE::class.java) } else { @Suppress("DEPRECATION") bundle.getSerializable(KEY_HOGE) as HOGE }
  10. Mobility Technologies Co., Ltd. 24 ▪ Compile SDK VersionͰ৽͘͠DeprecatedʹͳͬͨBundleͱIntentͷରԠ͕ͭ Β͍

    ▪ AppCompat͕·ͩରԠ͍ͯ͠ͳ͍ ▪ ରԠํ๏͸࣍ͷ2ͭ ▪ ࣗ࡞ͰόʔδϣϯΛ഑ྀ࣮ͯ͠૷ ▪ AppCompatʹ࣮૷͞ΕΔͷΛ଴ͭ ▪ ࣮૷͞ΕΔ·ͰSupress warning͢Δ ·ͱΊ
  11. Mobility Technologies Co., Ltd. 29 ▪ ͳΜͱ৽͍͠getParcelableʹ͸όά͕༗Δ ▪ ৚݅Λຬͨͨ͠ParcelableΛѻ͏ͱNullPointerException ▪

    API level 33ͷAPIͷόάͳͷͰमਖ਼͞ΕΔͱͯ͠΋API level 34 ▪ ݹ͍getParcelableΛsuppress warning͠ͳ͕Β࢖͏ͷ͕ແ೉ ▪ ѻ͏Parcelable͕ෆ۩߹Λ౿Ή৚݅Λຬ͍ͨͯ͠Δͷ͔൑ఆ͢Δͷ͸໘౗ ▪ ͋ͱͰParcelableͷΫϥεΛมߋͯ͠஍ཕΛ౿ΜͰ͠·͏͔΋
  12. Mobility Technologies Co., Ltd. 31 ▪ Compile SDK VersionͰ৽͘͠DeprecatedʹͳͬͨBundleͱIntentͷରԠ͕ ͭΒ͍

    ▪ AppCompat͸·ͩରԠ͍ͯ͠ͳ͍ ▪ ৽͍͠getParcelableʹ͸όά͕༗ΔͷͰɺsuppress warningͰݹ͍ getParcelableΛ࢖͏ͷ͕ແ೉ ▪ কདྷAppCompat͕ରԠͨ͠৔߹ɺ෼ذͷڥք͕Ͳͷόʔδϣϯʹͳ͍ͬͯΔ ͷ͔֬ೝ͔ͯ͠Β࢖͍·͠ΐ͏ ·ͱΊ