Using OKHttp3


// It is used to get JsonData from URL


new AsyncTask<Void, Void,String>() {

    @Override    protected String doInBackground(Void... voids) {
        OkHttpClient okHttp =  new OkHttpClient();
        Request request = new Request.Builder().url("https://api.github.com/users/ashokslsk").build();
        try {
            Response response = okHttp.newCall(request).execute();
            System.out.println("ResponseRupal:::::" + response.body().string());
            return  "Hi";
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}.execute();

Comments

Popular posts from this blog

How to Use Co-routine For Taking Touch Event in Unity(Mouse Event And Keyboard KeyEvent), Also Explained How to call coroutine from other script

Calling private method of other class which is not accessible.