How To Send Data To Server
Solution 1:
You can use OkHttp to achieve this easily. In order to include the library use the following in dependencies: compile 'com.squareup.okhttp3:okhttp:3.2.0'
As a sample you can use it like this:
RequestBodyformBody=newFormBody.Builder()
.add("username", USER_NAME)
.add("password", PASSWORD)
.build();
Requestrequest=newRequest.Builder()
.url(url)
.post(formBody)
.build();
OkHttpClientclient=newOkHttpClient();
Responseresponse= client.newCall(request).execute();
if(response.code == 200){
StringresponseData= responses.body().string();
//Process the response Data
}else{
//Server problem
}
Solution 2:
You can communicate Android mobile client with the server. This tutorial is a brief guide on how to integrate your Android App to WAMP Server. This server could be hosted on you local machine or on a remote server.
Solution 3:
You will have to use any networking library like volley,Retrofit or you can also use Httpurlconnection to send data to server.Here is an example of sending data to server using httpurlconnection. https://www.studytutorial.in/android-httpurlconnection-post-and-get-request-tutorial
Solution 4:
Follow these links for this
[1]:------ http://www.vogella.com/tutorials/Retrofit/article.html
[2]:------ http://www.androidhive.info/2016/05/android-working-with-retrofit-http-library/
Post a Comment for "How To Send Data To Server"