How to start Viber call from an Android app [new version]?

后端 未结 3 1509
旧时难觅i
旧时难觅i 2020-12-16 04:34

A while ago I created this post, and my colleague and I have found two different answers to it (both of them worked):

  1. First solution was to use

    Int

3条回答
  •  失恋的感觉
    2020-12-16 05:29

    According to Viber's manifest, there is activity "com.viber.voip.phone.PhoneActivity" that is responsible for action "com.viber.voip.action.CALL". In new version of Viber (4.2.1.1) this activity is marked by android:exported="false". As result, it's not possible anymore to start this activity from external applications...

    Edit

    This code opens welcome screen for specified contact

    String sphone = "12345678";
    Uri uri = Uri.parse("tel:" + Uri.encode(sphone)); 
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.setClassName("com.viber.voip", "com.viber.voip.WelcomeActivity");
    intent.setData(uri); 
    context.startActivity(intent);
    

    but user should click button "free call" to start call.

提交回复
热议问题