Hello, I’m an Android developer who is creating an app interacting with a streaming service. I’d like to add an “open with” button to start playing from yatse.
I’ve tried using the APIs on Yatse API but I can’t get it to work.
I already have a “share” button which let me select yatse and it’s already working.
I know the correct one should be
val intent = Intent().apply {
action = "org.leetzone.android.yatsewidget.ACTION_MEDIA_PLAYURI"
putExtra("org.leetzone.android.yatsewidget.EXTRA_STRING_PARAMS", url)
}
intent.startService(intent)
but the package is not found, I think because after deprecating the unlocker the correct package is org.leetzone.android.yatsewidget
Thisi s the code I’m using to test other explicit intents:
override fun onOpenWith(url: String) {
val pm = requireContext().packageManager
val intents: List<Intent> = listOf(
pm.getLaunchIntentForPackage("org.leetzone.android.yatsewidgetfree")!!.apply {
action = "org.leetzone.android.yatsewidget.ACTION_MEDIA_PLAYURI"
data = Uri.parse(url)
},
pm.getLaunchIntentForPackage("org.leetzone.android.yatsewidgetfree")!!.apply {
action = "org.leetzone.android.yatsewidget.ACTION_MEDIA_PLAYURI"
putExtra("org.leetzone.android.yatsewidget.EXTRA_STRING_PARAMS", url)
},
Intent().apply {
action = "org.leetzone.android.yatsewidget.ACTION_MEDIA_PLAYURI"
putExtra("org.leetzone.android.yatsewidget.EXTRA_STRING_PARAMS", url)
},
Intent().apply {
action = "org.leetzone.android.yatsewidget.ACTION_MEDIA_PLAYURI"
data = Uri.parse(url)
},
Intent().apply {
action = "org.leetzone.android.yatsewidgetfree.ACTION_MEDIA_PLAYURI"
putExtra("org.leetzone.android.yatsewidget.EXTRA_STRING_PARAMS", url)
},
Intent().apply {
action = "org.leetzone.android.yatsewidgetfree.ACTION_MEDIA_PLAYURI"
data = Uri.parse(url)
},
Intent().apply {
action = "org.leetzone.android.yatsewidgetfree.ACTION_MEDIA_PLAYURI"
putExtra("org.leetzone.android.yatsewidgetfree.EXTRA_STRING_PARAMS", url)
},
)
// Verify that the intent will resolve to an activity
context?.let {
intents.forEachIndexed { index, intent ->
if (intent.resolveActivity(it.packageManager) != null) {
it.showToast("yatseIntent $index")
it.startService(intent)
} else {
if (index == intents.size - 1)
it.showToast(R.string.app_not_installed)
}
}
}
}
The passed url is like “https://streaming.com/asdasd”
When I use the action org.leetzone.android.yatsewidget.ACTION_MEDIA_PLAYURI I get the package not installed message (since the package is org.leetzone.android.yatsewidgetfree), if I use the yatsewidgetfree action it does not give errors but it also does not start playing