I want to send SMS from my android app. I have the SID and AUTHTOKEN pasted below. Appreciate someone looking and giving some input or working code:
Issue : there seem to be multiple ways to do it - use twilio-java-sdk, twilioclient-android and using REST API.
Here is the code I tried with TwilioRestClient which throws error as :
public static void SendSMS() throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(Utils.TWILO_SID, Utils.TWILO_AUTH_TOKEN);
Map<String,String> map = new HashMap<>();
map.put("from", "4254434895");
map.put("to", "4254434294");
map.put("Body", "test message");
SmsFactory factory = client.getAccount().getSmsFactory();
Sms sms = factory.create(map);
Log.d("TwilioHelper", sms.getSid());
Log.d("TwilioHelper", sms.toString());
}
Error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.cyoo.app, PID: 3088
java.lang.NoSuchMethodError: No virtual method setDefaultMaxPerRoute(I)V in class Lorg/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager; or its super classes (declaration of 'org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager' appears in /system/framework/ext.jar)
at com.twilio.sdk.TwilioRestClient.<init>(TwilioRestClient.java:139)
at com.twilio.sdk.TwilioRestClient.<init>(TwilioRestClient.java:109)
at com.cyoo.app.TwilioHelper.SendSMS(TwilioHelper.java:16)
at com.cyoo.app.RegiserFinalActivity$2.onClick(RegiserFinalActivity.java:71)
at android.view.View.performClick(View.java:4785)
I will appreciate anyone throwing some sample working code. -Thanks