mirror of
https://github.com/KRTirtho/spotube.git
synced 2026-11-04 10:13:59 +00:00
fix(android): update sharing functionality to use chooser intent with new task flag
This commit is contained in:
parent
38e9bbc1d8
commit
9d5854023b
@ -18,15 +18,19 @@
|
|||||||
package org.spotube.spotube.core.share
|
package org.spotube.spotube.core.share
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import androidx.core.app.ShareCompat
|
import androidx.core.app.ShareCompat
|
||||||
import org.spotube.spotube.core.share.ShareService
|
import org.spotube.spotube.core.share.ShareService
|
||||||
|
|
||||||
class AndroidShareService(private val context: Context) : ShareService {
|
class AndroidShareService(private val context: Context) : ShareService {
|
||||||
override fun share(url: String, title: String) {
|
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")
|
.setType("text/plain")
|
||||||
.setSubject(title)
|
.setSubject(title)
|
||||||
.setText(url)
|
.setText(url)
|
||||||
.startChooser()
|
.createChooserIntent()
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
context.startActivity(chooser)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user