public class MainActivity extends AppCompatActivity implements View.OnClickListener {
     
        private static final String link = "http://jsonparsing.parseapp.com/jsonData/moviesDemoItem.txt";
        private String data = "";
        private HttpURLConnection connection;
        private BufferedReader reader;
        private Button btnHit;
        private  TextView tvData;
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
     
            btnHit = (Button) findViewById(R.id.btnHit);
            tvData = (TextView) findViewById(R.id.text);
     
            btnHit.setOnClickListener(this);
        }
     
        @Override
        public void onClick(View view) {
            new JSONTask().execute(link);
        }
     
        public class JSONTask extends AsyncTask<String, String, String>{
     
            @Override
            protected String doInBackground(String... params) {
                try {
                    URL url = new URL(params[0]);
                    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                    reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
     
                    String line = null;
     
                    while ((line = reader.readLine()) != null) {
                        data += line;
                    }
     
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return data;
            }
     
            @Override
            protected void onPostExecute(String result) {
                super.onPostExecute(result);
                getJSON(result);
            }
        }
     
        private void getJSON(String data){
    try {
            JSONObject object = new JSONObject(DATA);
            JSONArray arr = object.getJSONArray("JSON-ARRAY-NAME");
            for (int i = 0; i < arr.length(); i++){
                JSONObject jsonObject = arr.getJSONObject(i);
                Toast.makeText(this, jsonObject.getString("JSON-OBJECT-NAME"), Toast.LENGTH_SHORT).show();
             //   tvData.setText(jsonObject.getString("movie"));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
     
    }