You can use this method to obtain or publish any purpose. Just use this method to query the server.
public void RequestToServer() { // String User_id = "h"; AsyncHttpClient client = new AsyncHttpClient(); RequestParams params = new RequestParams(); // params.put("uid", User_id.toString()); client.post("http:// Your Url", params, new AsyncHttpResponseHandler() { @Override public void onSuccess(String s) { super.onSuccess(s); Log.d("Server Response for success :", s); tv.append("service_ReloadSqlDB" + " " + s); } @Override public void onFailure(Throwable throwable) { super.onFailure(throwable); Log.d("Server Response for onFailure ", throwable.toString()); } }); }
You also need the file jar = android-async-http-1.3.1.jar download this jar and add your android project to the libs folder After that, add this to your build.gradle
dependencies { compile files('libs/<android-async-http-1.3.1.jar>') }
Finally, rebuild your project, run the application, get a response from your server.
source share