I need to get some data from external server in an android app. for that i use
com.loopj.android:android-async-http:1.4.9
But my app crashed while initiating client in MainActivity
private MyClient client;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
client = new MyCLient();
}
Then, if I run the app, it crashes. except new MyCLient() app is ok.
MyClient.java
package com.example.hellow;
import com.loopj.android.http.*;
public class MyClient {
private static final String BASE_URL = "https://httpbin.org/";
private static AsyncHttpClient client = new AsyncHttpClient();
public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
client.get(getAbsoluteUrl(url), params, responseHandler);
}
public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
client.post(getAbsoluteUrl(url), params, responseHandler);
}
private static String getAbsoluteUrl(String relativeUrl) {
return BASE_URL + relativeUrl;
}
}