Last active
June 20, 2017 13:44
-
-
Save adastreamer/8e10eda47bf936e0d456c1f1e312c9ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void makeRequest(final String url, final String json) { | |
Runnable runable = new Runnable() { | |
public void run() { | |
try{ | |
OkHttpClient client = new OkHttpClient(); | |
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), json); | |
Request request = new Request.Builder() | |
.header("User-Agent", "Mozilla/5.0 (Linux; Android 6.0.1; SM-webview_android_dl Build/MMB29K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36") | |
.addHeader("Content-Type","application/json") | |
.url(url) | |
.post(body) | |
.build(); | |
client.newCall(request).execute(); | |
}catch(Exception e){ | |
e.printStackTrace(); | |
} | |
} | |
}; | |
Thread thread = new Thread(runable); | |
thread.start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment