使用Intent在Android上的Tiktok应用程序中打开用户页面

时间:2018-11-16 20:18:34

标签: android android-intent

是否存在类似于Soundcloud Uri(“ soundcloud:// users:” +“ soundcloud_username”)的内容,允许应用程序用户打开Tiktok应用程序并转到另一个用户页面,例如下面的Soundcloud代码?

Soundcloud代码参考:强制在Android的Soundcloud应用中打开Soundcloud曲目

        try {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("soundcloud://users:" + "soundcloud_username"));
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://soundcloud.com/"+string_soundcloudLink_profile)));
        }

2 个答案:

答案 0 :(得分:0)

嘿,我在xamarin.android中找到了解决方案

private void urlclick(object sender, EventArgs e)
            {

                PackageManager manager = PackageManager;
                var U =Android.Net.Uri.Parse("http://vm.tiktok.com/tiktokulr");///Add URL of you tiktok account  
                Intent i;
                Intent icheck;
                try
                {
                    i = new Intent(Intent.ActionView, U);

                    icheck = manager.GetLaunchIntentForPackage("com.zhiliaoapp.musically");
                    if (icheck == null)
                    {
                        Toast.MakeText(this, "please install tiktok in your phone", ToastLength.Short).Show();
                        throw new PackageManager.NameNotFoundException();
                    }
                    else
                    {

                        StartActivity(i);
                    }

                }
                catch (PackageManager.NameNotFoundException exp)
                {

                }

答案 1 :(得分:0)

private fun openTikTokProfile() {
    val uri: Uri = Uri.parse("https://www.tiktok.com/@${username}")
    val intent = Intent(Intent.ACTION_VIEW, uri)

    intent.setPackage("com.zhiliaoapp.musically")

    if (intent.resolveActivity(requireActivity().packageManager) != null) {
        startActivity(intent)
    }
}