How To Start Viber Call From An Android App?
I am developing an Android application, and besides other functionalities it has to be able to place a call using Viber. I tried to use solution for Skype but without success. Erro
Solution 1:
This problem was resolved with this piece of code:
publicvoidcall(String dialNumber) {
try{
IntentcallIntent=newIntent("android.intent.action.CALL_PRIVILEGED");
callIntent.setData(Uri.parse("tel:" + dialNumber));
startActivity(callIntent);
}
catch (Exception e) {
IntentcallIntent=newIntent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + dialNumber));
startActivity(callIntent);
}
}
where this was crucial: "android.intent.action.CALL_PRIVILEGED"
After applying this, new window was opened offering for call to be made by all possible means for placing call - in this particular case, they were Dialer and Viber and Skype (or any other method added later).
Solution 2:
If you want to start Viber explicitly to call specific phone number:
IntentlocalIntent4=newIntent("com.viber.voip.action.CALL");
localIntent4.setType("vnd.android.cursor.item/vnd.com.viber.voip.call");
localIntent4.setData(Uri.parse("tel:" + phone_number_to_call));
localIntent4.putExtra("external_call", true);
localIntent4.putExtra("contact_id", -1L);
startActivity(localIntent4);
All you need to do is to initialize variable phone_number_to_call as you wish.
Post a Comment for "How To Start Viber Call From An Android App?"