I am creating an app where user clicks on different social media links. The links are from different media including Facebook, Youtube and WhatsApp etc.
What I want is:
When user clicks on a Facebook link, the program checks if there is Facebook app installed in the user's phone and open the link in it. Similarly for other media.
I have tried a little with this code:
Intent intent=new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);
But it opens all the link in browser. I am new to android, kindly help! Thanks in advance...
The package name can be used to launch the application.
Intent intent = getPackageManager().getLaunchIntentForPackage("com.package.name");
if (intent != null) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
// Open GooglePlay link to install the app
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With