Waterfall
Waterfall

Reputation: 101

send message direct to phonenumber viber from android app

hi i want send message from my app with viber intent , my code

Intent share = new Intent(android.content.Intent.ACTION_SEND);
                share.setClassName("com.viber.voip","com.viber.voip");
                share.setType("text/plain");
                Uri uri =Uri.parse("tel:"+Uri.encode("09359128332"));
                share.putExtra(Intent.EXTRA_TEXT, "Your text to share");
                share.setData(uri); 
                MainActivity.this.startActivity(share);

i can send message to viber but must be select some user , but i want direct sent message to phone number wuth viber , this code not work any one can help

Upvotes: 3

Views: 3349

Answers (1)

cesarak
cesarak

Reputation: 136

you should do

public void startViber() {
  Uri uri = Uri.parse("smsto:+55" + viber_contact);
  Intent waIntent = new Intent(Intent.ACTION_SENDTO, uri);
  waIntent.setPackage("com.viber.voip");
  startActivity(Intent.createChooser(waIntent, "Share"));
  hideProgressBar();
}

In our case, we put the +55 before the number to send messages to Brazil country. Cheers

Upvotes: 2

Related Questions