Open telegram channel in android
Intent for opening a Telegram channel or user :
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tg://resolve?domain=partsilicon"));
startActivity(intent);
Answer @Saurabh Padwekar is good, but i want tell that you probably need add queries for Android SDK 30+ like this:
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tg" />
</intent>
</queries>
First check if any telegram client (telegram messenger or telegram x) is installed. If not open it in browser.
fun telegramIntent(context: Context): Intent {
var intent: Intent? = null
try {
try {
context.packageManager.getPackageInfo("org.telegram.messenger", 0)//Check for Telegram Messenger App
} catch (e : Exception){
context.packageManager.getPackageInfo("org.thunderdog.challegram", 0)//Check for Telegram X App
}
intent = Intent(Intent.ACTION_VIEW, Uri.parse("tg://resolve?domain=${TELEGRAM_PAGE_ID}"))
}catch (e : Exception){ //App not found open in browser
intent = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.telegram.me/$TELEGRAM_PAGE_ID"))
}
return intent!!
}