0

I want to place a call programmatically from my App to Viber. I know this question asked many times in SO. but as a matter of fact, none of them works now (in the newer version).

I've tried this SO post. But as mentioned in the answer. the user has to go through two steps to make a call.

I know it is possible to place a call by just one click from app. (Reference: this play store app is successfully placing a call from their app to viber.)

Currently, i'm using this

  String sphone = "+xxxxxxxxxx";
  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);
  startActivity(intent);

But as I mentioned user have to go through two steps to make a call. I've tried all solutions and also read viber docs but can't find anything. If anyone aware of how to do it in the newer version would be helpful to many developers.

Jaymin
  • 2,879
  • 3
  • 19
  • 35
Tejas Pandya
  • 3,987
  • 1
  • 26
  • 51
  • @RonTLV thanks for you comment. but please have a look at my mentioned link in question. comment link you attached and my mentioned link both are asked by same user and mine is latest one by that user – Tejas Pandya Jan 25 '18 at 10:02

1 Answers1

0

Try the following method

public void call(String dialNumber) {
    try{
    Intent callIntent = new Intent("android.intent.action.CALL_PRIVILEGED");
    callIntent.setData(Uri.parse("tel:" + dialNumber));
    startActivity(callIntent);
    }
    catch (Exception e) {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:" + dialNumber));
        startActivity(callIntent);
    }
}

where this was crucial: "android.intent.action.CALL_PRIVILEGED".
Find source here.

devgun
  • 1,003
  • 13
  • 33
  • thank you for your answer . but please have a look at my mentioned link in question. source link you attach and my mentioned link both are asked by same user and mine is latest one by that user . – Tejas Pandya Jan 25 '18 at 09:59