diff --git a/composeApp/src/androidMain/kotlin/org/spotube/spotube/core/share/AndroidShareService.kt b/composeApp/src/androidMain/kotlin/org/spotube/spotube/core/share/AndroidShareService.kt index 91a7a02e..f75039e5 100644 --- a/composeApp/src/androidMain/kotlin/org/spotube/spotube/core/share/AndroidShareService.kt +++ b/composeApp/src/androidMain/kotlin/org/spotube/spotube/core/share/AndroidShareService.kt @@ -18,15 +18,19 @@ package org.spotube.spotube.core.share import android.content.Context +import android.content.Intent import androidx.core.app.ShareCompat import org.spotube.spotube.core.share.ShareService class AndroidShareService(private val context: Context) : ShareService { override fun share(url: String, title: String) { - ShareCompat.IntentBuilder(context) + // context is the application context (Koin), which can only start activities in a new task + val chooser = ShareCompat.IntentBuilder(context) .setType("text/plain") .setSubject(title) .setText(url) - .startChooser() + .createChooserIntent() + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + context.startActivity(chooser) } }