0

I have an application about live streamer on dailymotion platform. Dailymotion have a websdk (in json). I didn't know how use json in android. I want to know how do an action if dailymotion live is on or off. And i want we check json all x minutes.

The JSON : https://api.dailymotion.com/video/x3p6d9r?fields=onair

Any suggestions please.

Vamsi Abbineni
  • 479
  • 3
  • 7
  • 23
johnsnow85
  • 125
  • 1
  • 2
  • 9
  • google for `android json`, and then google for `android run code over time` to find the answer to your 2 questions. You will spend not more than a minute. – Vladyslav Matviienko Aug 30 '16 at 12:15

1 Answers1

1

Basically, In android you will have to parse JSON response either manually or using some Third party library.

e.g. if you have JSON response like follows:

{
   "pageInfo": {
         "pageName": "abc",
         "pagePic": "http://example.com/content.jpg"
    }
    "posts": [
         {
              "post_id": "123456789012_123456789012",
              "actor_id": "1234567890",
              "picOfPersonWhoPosted": "http://example.com/photo.jpg",
              "nameOfPersonWhoPosted": "Jane Doe",
              "message": "Sounds cool. Can't wait to see it!",
              "likesCount": "2",
              "comments": [],
              "timeOfPost": "1234567890"
         }
    ]
}

Then you can parse the above response as follows: import org.json.*;

JSONObject obj = new JSONObject(" .... ");
String pageName = obj.getJSONObject("pageInfo").getString("pageName");

JSONArray arr = obj.getJSONArray("posts");
for (int i = 0; i < arr.length(); i++)
{ 
    String post_id = arr.getJSONObject(i).getString("post_id");
    ...... 
} 

You can also parse the above response using GSON library or some other library.

Rajendra
  • 484
  • 4
  • 19