any one know why when using registerForActivityRes...
# android
m
any one know why when using registerForActivityResult in BottomSheetDialogFragment the ide say Unresolved reference: registerForActivityResult error but it runs fine
t
Probably an inconsistency between code and IDE. Does cleaning cache and restarting IDE solves the problem ?
m
no
t
Please share your dependencies and a code snippet
m
i am using material 1.3.0-alpha02 maybe that?
full dependecies dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') coreLibraryDesugaring 'com.android.toolsdesugar jdk libs1.0.10' implementation "org.jetbrains.kotlinkotlin stdlib jdk7$kotlin_version" implementation 'org.jetbrains.kotlinxkotlinx coroutines android1.3.8' implementation 'org.jetbrains.kotlinxkotlinx coroutines play services1.3.8' implementation 'androidx.corecore ktx1.5.0-alpha01' implementation 'androidx.appcompatappcompat1.3.0-alpha01' implementation 'androidx.activityactivity ktx1.2.0-alpha07' implementation 'androidx.fragmentfragment ktx1.3.0-alpha07' implementation 'androidx.lifecyclelifecycle livedata ktx2.3.0-alpha06' implementation 'androidx.lifecyclelifecycle viewmodel ktx2.3.0-alpha06' implementation 'androidx.lifecyclelifecycle viewmodel savedstate2.3.0-alpha06' implementation 'androidx.lifecyclelifecycle runtime ktx2.3.0-alpha06' implementation 'androidx.lifecyclelifecycle process2.3.0-alpha06' implementation 'androidx.navigationnavigation fragment ktx2.3.0' implementation 'androidx.navigationnavigation ui ktx2.3.0' implementation 'androidx.roomroom runtime2.3.0-alpha02' implementation 'androidx.roomroom ktx2.3.0-alpha02' kapt 'androidx.roomroom compiler2.3.0-alpha02' implementation 'androidx.workwork runtime ktx2.4.0' implementation 'androidx.workwork gcm2.4.0' implementation 'androidx.constraintlayoutconstraintlayout2.0.0-rc1' implementation "androidx.preferencepreference ktx1.1.1" implementation "androidx.recyclerviewrecyclerview1.2.0-alpha05" implementation "androidx.viewpager2viewpager21.1.0-alpha01" implementation "androidx.swiperefreshlayoutswiperefreshlayout1.2.0-alpha01" implementation 'com.google.android.materialmaterial1.3.0-alpha02' implementation "io.github.reactivecircus.flowbindingflowbinding android1.0.0-alpha02" implementation "io.github.reactivecircus.flowbindingflowbinding material1.0.0-alpha02" implementation 'io.github.reactivecircus.flowbindingflowbinding recyclerview1.0.0-alpha02' implementation 'io.github.reactivecircus.flowbindingflowbinding swiperefreshlayout1.0.0-alpha02' implementation 'com.jakewharton.timbertimber4.7.1' implementation 'com.squareup.retrofit2retrofit2.9.0' implementation 'com.squareup.retrofit2converter moshi2.9.0' implementation 'com.squareup.okhttp3okhttp4.8.1' implementation 'com.squareup.okhttp3okhttp urlconnection4.8.1' implementation 'com.squareup.okhttp3logging interceptor4.8.1' implementation "org.koinkoin android2.1.6" implementation "org.koinkoin androidx scope2.1.6" implementation 'org.koinkoin androidx viewmodel2.1.6' implementation 'com.google.firebasefirebase messaging20.2.4' implementation 'com.google.firebasefirebase crashlytics ktx17.1.1' implementation 'com.google.firebasefirebase analytics ktx17.4.4' implementation 'com.google.firebasefirebase perf19.0.8' implementation 'com.google.firebasefirebase config ktx19.2.0' implementation 'com.github.PhilJayMPAndroidChartv3.1.0' implementation 'com.blankjutilcodex1.29.0' implementation 'com.squareup.moshimoshi1.9.3' kapt('com.squareup.moshimoshi kotlin codegen1.9.3') implementation('io.coil-ktcoil0.11.0') implementation('io.coil-ktcoil svg0.11.0') implementation 'com.wdullaermaterialdatetimepicker4.2.3' implementation 'com.airbnb.androidepoxy4.0.0-beta6' kapt 'com.airbnb.androidepoxy processor4.0.0-beta6' implementation 'com.tunjid.androidxrecyclerview1.1.0-alpha01' implementation 'com.freeletics.flowreduxflowredux0.3.0' implementation 'com.freeletics.flowreduxdsl0.3.0' implementation 'io.michaelrockslibphonenumber android8.12.6' implementation 'com.google.android.playcore ktx1.8.1' implementation 'com.vanniktechemoji google0.6.0' implementation 'com.airbnb.androidlottie3.4.1' implementation 'com.google.android.exoplayerexoplayer2.11.7' def arrow_version = "0.10.5" implementation "io.arrow-ktarrow optics$arrow_version" implementation "io.arrow-ktarrow syntax$arrow_version" kapt "io.arrow-ktarrow meta$arrow_version" implementation('dev.doubledot.dokilibrary0.0.1@aar') { transitive = true } }
private val getDocuments = registerForActivityResult(ActivityResultContracts.GetMultipleContents()) { it?.let { urisList -> } }
b
That method is activity based iirc.
activity?.registerFor[...]
m
still same error
b
. Cast it to ComponentActivity
m
yup thanks that worked
but it works in fragments without that. isn't BottomSheetDialogFragment extend Fragments in the end
318 Views