icerockdev / moko-geo

Geolocation access for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
176 stars 16 forks source link

Couldn't use with ComponentActivity, bind issue #48

Closed prabinshrestha closed 2 months ago

prabinshrestha commented 5 months ago

I am using 0.6.0 library integrated for my multiplatform project and found out it doesnot work with ComponentActivity.

MainActivity which extends ComponentActivity(from official android) cannot be cast to androidx.fragment.app.FragmentActivity

fun BindMyLocationTrackerEffect(locationTracker: LocationTracker) { val lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current val context: Context = LocalContext.current

LaunchedEffect(locationTracker, lifecycleOwner, context) {
    val fragmentManager: FragmentManager = (context as FragmentActivity).supportFragmentManager // this part has an issue
    locationTracker.bind(lifecycleOwner.lifecycle, context, fragmentManager)
}

}

the current solution is to use AppCompatActivity but i want to utilize latest ComponentActivity from android

Alex009 commented 2 months ago

will be released in 0.7.0