我基本上希望我的按钮打开tiktok视频链接(链接应该由tiktok应用程序打开,而不是默认浏览器或webview)点击。如何在Android中编写该按钮?
发布于 2021-11-28 17:23:33
也许是一个迟来的答案,但你能做的不仅仅是TikTok,还有你想要从安卓应用程序中打开它的任何其他应用程序,就是使用它的包名,并正常使用意图打开它,例如打开Instagram的代码。
url = "https://instagram.com/p/imagecode"
Uri uri = Uri.parse(url);
Intent likeIng = new Intent(Intent.ACTION_VIEW, URI);
likeIng.setPackage("com.instagram.android"); // -> here is the part 
try {
     startActivity(likeIng);
 } catch (ActivityNotFoundException e) {
    //catch the Error if the app not installed.
 }您可以从Google本身获得包名,它包含包名,对于TikTok,包名是com.ss.android.ugc.trill,所以您可以使用上面的代码来打开它,我没有用TikTok测试它,但是它是用Instagram测试的,所以我认为同样的逻辑也适用。
https://stackoverflow.com/questions/68010950
复制相似问题