android - Send message body and phone number to Viber -


I try to get messages and phone numbers in my app and then send a message to that number, I want to send a message via Viber application, I can send a message with this code:

  intent = new intention (int. Action_snnd); Intent.setType ("text / plain"); Intent.putExtra (android.content.Intent.EXTRA_TEXT, "Test Test Test"); Intent.setpackage ("com.viber.voip"); StartActivity;  

How can I send a phone number to Viber?

There are two ways to send messages using the intents for Viber.

Option A - Unfortunately sms_body will not be filled up. But the dialog will open directly with the specific contact:

  intent smsIntent = new intent (Intent.ACTION_SENDTO); SmsIntent.addCategory (Intent.CATEGORY_DEFAULT); SmsIntent.setPackage ("com.viber.voip"); SmsIntent.setData (Uri.parse ("SMS: +1001002003"); SmsIntent.putExtra ("address", "+1001002003"); SmsIntent.putExtra ("sms_body", "body text"); StartActivity (smsIntent);  

Option B - You will get an option that the user should receive the message:

  intent = new intent (intent . Actions_SEND); I.setPackage ("com.viber.voip"); I.setType ("text / plain"); I.putExtra (Intent.EXTRA_TEXT, "Message Body");  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -