I'm developing an app where I want to show total subscribers of a YouTube channel using JSON
, AsyncTask
, TextView
. I don't know how to parse a JSON data. Please help me!
My problem has been solved HERE
The JSON API link HERE
https://www.googleapis.com/youtube/v3/channels?part=statistics&id=UCtjgLjaefEi4kcWBl5rpoZg&fields=items/statistics/subscriberCount&key=AIzaSyBU_oWEIULi3-n96vWKETYCMsldYDAlz2M
The JSON file itself
JSON.java class
public class JSON extends AsyncTask<String, String, JSONObject> {
String link = "https://www.googleapis.com/youtube/v3/channels?part=statistics&id=" +
"UCtjgLjaefEi4kcWBl5rpoZg&fields=items/statistics/subscriberCount&key=AIzaSyBU_oWEIULi3-n96vWKETYCMsldYDAlz2M";
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected JSONObject doInBackground(String... args) {
return null;
}
@Override
protected void onPostExecute(JSONObject json) {
}
}
My main activity
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tv = (TextView) findViewById(R.id.textView);
}
I desperately need some help, please don't avoid this question!
A simple Google would have yielded you the guidance you needed. There's an Android JSON Parsing Tutorial in Android Hive. Also check this SO post for more info.