title: Android - open Telegram specific account from my own Android app
body: <p>could you help me if you know. I am trying to open Telegram app with needed contact and I tried two diffrent ways and noone is not working.</p>
  
  <p>First way: 
  1) I got userId, for example 1111111111 and if I open it from WEB it works fine: <a href="https://web.telegram.org/#/im?p=u1111111111" rel="nofollow noreferrer">https://web.telegram.org/#/im?p=u1111111111</a>, but when I am trying to launch it from my app id doesn't work and always toast me "there is no Telegram account with this username":</p>
  
  <p>The code next:</p>
  
  <pre><code>Intent telegram = new Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/1111111111")); //where 1111111111 - telegram userId
  telegram.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  telegram.setPackage("org.telegram.messenger");
  startActivity(telegram);
  </code></pre>
  
  <p>I asked Telegram support and they told me that url "<a href="https://t.me/" rel="nofollow noreferrer">https://t.me/</a> " can be used only with UserNames not UserId and did not give me any <strong>url</strong> that can be used for UserId. But UserNames cannot be got easily as well not every user has UserName.</p>
  
  <p>Then I tried second way using URI scheme:</p>
  
  <pre><code>Intent telegram = new Intent(Intent.ACTION_VIEW);
  telegram.setData(Uri.parse("tg://msg?text=Hello&amp;to=+496........."));
  telegram.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  telegram.setPackage("org.telegram.messenger");
  context.startActivity(telegram);
  </code></pre>
  
  <p>But it doesn't open needed contact only launch Telegram app. All contacts what I try are exist in my phone book. Why this URI scheme is not working?</p>
  
  <p>"tg://msg?text=Hello&amp;to=+496........."</p>
  
  <p>If I use this scheme "tg://resolve?domain=BotSupport" it is works fine and opens the chat with bot, but I need to open contact from my phone book.</p>
  
  <p>Maybe somebody had the same problem?</p>
  
  <p>Thank you in advance.</p>