You can't check weather app installed or not from it's link. Package name is required for identifying App.
To check App Installed or not use following Function.
public boolean appInstalledOrNot(Context context, String paramString) {
PackageManager localPackageManager = context.getPackageManager();
try {
//noinspection WrongConstant
localPackageManager.getPackageInfo(paramString, 1);
return true;
} catch (PackageManager.NameNotFoundException ignored) {
}
return false;
}
Try this for Opening native App
String facebookPackage = "com.facebook.katana";
if (appInstalledOrNot(this,facebookPackage )) {
String url = "https://m.facebook.com";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
} else {
String url = "https://www.facebook.com";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
}
NOTE : if you are looking for package name of facebook and twitter
com.facebook.katana - Facebook
com.twitter.android - Twtter