I want to code redirection from my app to telegram. I didnt find any examples of it, so I tried to do it by the same way like I did with WhatsApp redirection, it didn't work, could you give me some advise? Below my code of WhatsApp redirection, it works, I tried the same by replacing strings "whatsapp" with "telegram", result is it goes to catch() when it checks the existance of package:
PackageManager pm=getPackageManager();
try {
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
PackageInfo info=pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
//Check if package exists or not. If not then code
//in catch block will be called
waIntent.setPackage("com.whatsapp");
waIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(waIntent, "Share with"));
} catch (PackageManager.NameNotFoundException e) {
Toast.makeText(this, "WhatsApp is not installed", Toast.LENGTH_SHORT)
.show();
}