Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getJSON("http://app.nurnobishanto.com/livetvadmin/custom-api.php?slider",1);
- getJSON("http://app.nurnobishanto.com/livetvadmin/custom-api.php?features",2);
- getJSON("http://app.nurnobishanto.com/livetvadmin/custom-api.php?info",3);
- private void getJSON(final String urlWebService, int b) {
- class GetJSON extends AsyncTask<Void, Void, String> {
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- }
- @Override
- protected void onPostExecute(String s) {
- super.onPostExecute(s);
- // Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
- try {
- if(b==1){
- loadIntoListView(s);
- }else if(b==2) {
- loadIntoListView2(s);
- }else if(b==3){
- loadInfo(s);
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- @Override
- protected String doInBackground(Void... voids) {
- try {
- URL url = new URL(urlWebService);
- HttpURLConnection con = (HttpURLConnection) url.openConnection();
- StringBuilder sb = new StringBuilder();
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
- String json;
- while ((json = bufferedReader.readLine()) != null) {
- sb.append(json + "\n");
- }
- return sb.toString().trim();
- } catch (Exception e) {
- return null;
- }
- }
- }
- GetJSON getJSON = new GetJSON();
- getJSON.execute();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement