@@ -24,25 +24,35 @@ public class Mobtexting {
2424 private static final String TAG = "Communicator" ;
2525 private static final String SERVER_URL = "http://api.mobtexting.com" ;
2626 private Retrofit retrofit ;
27- private String api_key1 ,sender_id ;
27+ private String api_key1 , sender_id ;
2828 private Context context ;
2929
30- public Mobtexting (Context context ){
31- this .context =context ;
30+ /**
31+ * @param context
32+ */
33+ public Mobtexting (Context context ) {
34+ this .context = context ;
3235 }
3336
37+ /**
38+ * send SMS using POST method
39+ *
40+ * @param message
41+ * @param mobile_no
42+ * @param mobtextingInterface
43+ */
3444 public void sendSMS (String message , String mobile_no , final MobtextingInterface mobtextingInterface ) {
3545 try {
3646 ApplicationInfo ai = context .getPackageManager ().getApplicationInfo (context .getPackageName (), PackageManager .GET_META_DATA );
3747 Bundle bundle = ai .metaData ;
38- api_key1 = bundle .getString ("mobtexting.api_key" );
39- sender_id = bundle .getString ("mobtexting.sender_id" );
40- }catch (Exception e ){
48+ api_key1 = bundle .getString ("mobtexting.api_key" );
49+ sender_id = bundle .getString ("mobtexting.sender_id" );
50+ } catch (Exception e ) {
4151 mobtextingInterface .onError (new ModelError ("100" , "API key" , "Dear developer. Don't forget to configure <meta-data android:name=\" mobtexting.api_key\" android:value=\" testValue\" /> in your AndroidManifest.xml file." ));
4252 return ;
4353 }
44- if (api_key1 != null && !api_key1 .equals ("" )) {
45- if (sender_id != null && !sender_id .equals ("" )) {
54+ if (api_key1 != null && !api_key1 .equals ("" )) {
55+ if (sender_id != null && !sender_id .equals ("" )) {
4656 HttpLoggingInterceptor logging = new HttpLoggingInterceptor ();
4757 logging .setLevel (HttpLoggingInterceptor .Level .BODY );
4858 OkHttpClient .Builder httpClient = new OkHttpClient .Builder ();
@@ -82,46 +92,12 @@ public void onFailure(Call<ServerResponse> call, Throwable t) {
8292 mobtextingInterface .onError (new ModelError ("500" , "No Internet" , "Check your internet connection!" ));
8393 }
8494 });
85- }else {
95+ } else {
8696 mobtextingInterface .onError (new ModelError ("100" , "Sender ID" , "Dear developer. Don't forget to configure <meta-data android:name=\" mobtexting.sender_id\" android:value=\" testValue\" /> in your AndroidManifest.xml file." ));
8797 }
88- }else {
98+ } else {
8999 mobtextingInterface .onError (new ModelError ("100" , "API key" , "Dear developer. Don't forget to configure <meta-data android:name=\" mobtexting.api_key\" android:value=\" testValue\" /> in your AndroidManifest.xml file." ));
90100 }
91101 }
92-
93- /*public void loginGet(String username, String password) {
94-
95- HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
96- logging.setLevel(HttpLoggingInterceptor.Level.BODY);
97- OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
98- httpClient.addInterceptor(logging);
99-
100- Retrofit retrofit = new Retrofit.Builder()
101- .client(httpClient.build())
102- .addConverterFactory(GsonConverterFactory.create())
103- .baseUrl(SERVER_URL)
104- .build();
105-
106- Interface service = retrofit.create(Interface.class);
107-
108- Call<ServerResponse> call = service.get("login", username, password);
109-
110- call.enqueue(new Callback<ServerResponse>() {
111- @Override
112- public void onResponse(Call<ServerResponse> call, Response<ServerResponse> response) {
113- // response.isSuccessful() is true if the response code is 2xx
114- Log.e(TAG, "Success");
115- }
116-
117- @Override
118- public void onFailure(Call<ServerResponse> call, Throwable t) {
119- // handle execution failures like no internet connectivity
120- Log.d("internet",t.getMessage());
121- }
122- });
123- }*/
124-
125-
126102}
127103
0 commit comments