Calling viber. Android

There is a task, by clicking on the button, to open a chat in Viber with the specified contact. Here is the code I use:

Intent viber = new Intent(Intent.ACTION_VIEW);
viber.setData(Uri.parse("viber://chat?number=" + phone));
startActivity(viber);

As a result, if the viber was opened before (minimized), then I go to the chat I need, but if the viber is not running, it gives me an error after a pause of 2-3 seconds: "No network. Error connecting to Viber services. Check your connection and try again." If you click on the button a second time after receiving the error, it is normal opens a chat with the right person...

How to cure this problem, so that the opening of Viber is always stable, and not every other time with errors?

I also tried calling viber by accessing its Activity:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.viber.voip", "com.viber.voip.WelcomeActivity");
intent.setData(Uri.parse("tel:" + Uri.encode(phone)));
startActivity(intent);

This option is not quite suitable for me, since this option is not possible to go directly to a chat with a specific person...

Author: Андрей Галкин, 2020-09-13