I basically want my button to open tiktok video link (link should be opened by tiktok app, not default browser or webview) on click. How to program that button in Android Studio?
Asked
Active
Viewed 1,791 times
1 Answers
2
maybe a late answer, but what you can do for not only TikTok, but any other app you want to open it from your Android application is to use the package name of it and open it using intent normally, example code to open Instagram for example.
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.
}
you can get the package name from Google play URL itself it contains the package name, for TikTok, the package name is com.ss.android.ugc.trill
so you can use it to open it using the above code, I did not test it with TikTok, but it's tested with Instagram, so I think the same logic applies.

user7179690
- 1,051
- 3
- 17
- 40
-
1It's always a good time for an answer. This is the correct answer. i.setPackage("com.ss.android.ugc.trill"); (Looks like tiktok changed package name, it was "com.zhiliaoapp.musically.go"). Also, link should be in form vm.tiktok.com/videoID (link can be obtained through tiktok app -> share -> copy link) – Rastko Stamenkovic Nov 29 '21 at 00:30
-
1thank you for clearing the right package name, please feel free to mark it as an answer if it helped, have a nice day. – user7179690 Nov 29 '21 at 11:02
-
1Your answer is accepted one now. Best regards! – Rastko Stamenkovic Nov 29 '21 at 23:37
-
1This is update to my first comment. Tiktok made change. Now, the tiktok video link should be in format: https://www.tiktok.com/@username/video/videoID – Rastko Stamenkovic Dec 06 '21 at 10:17