Android
android http post 전송
우유빛
2018. 4. 2. 11:52
build.gradle
compile 'com.squareup.okhttp3:okhttp:3.2.0'
private void sendRegistrationToServer(String token) {
OkHttpClient client = new OkHttpClient();
RequestBody body = new FormBody.Builder()
.add("Token", token)
.build();
//request
Request request = new Request.Builder()
.url("http://서버주소/")
.post(body)
.build();
try {
client.newCall(request).execute();
} catch (IOException e) {
e.printStackTrace();
}
}