0

I am new to Java on Android. I'd like to fetch all titles and images from this URL. I am unable to fetch all those as they are not present in single array.

https://commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&iiprop=timestamp%7Cuser%7Curl&generator=categorymembers&gcmtype=file&gcmtitle=Category:Featured_pictures_on_Wikimedia_Commons&format=json&utf8

Content goes like:

{
   "batchcomplete":"",
   "continue":{
      "gcmcontinue":"file|3030312043484154454155204445204348494c4c4f4e20414e442044454e5453204455204d4944492050484f544f2042592047494c4553204c415552454e542e4a50470a3030312043484154454155204445204348494c4c4f4e20414e442044454e5453204455204d4944492050484f544f2042592047494c4553204c415552454e542e4a5047|96559561",
      "continue":"gcmcontinue||"
   },
   "query":{
      "pages":{
         "49179423":{
            "pageid":49179423,
            "ns":6,
            "title":"File:\"Broke, baby sick, and car trouble!\" - Dorothea Lange's photo of a Missouri family of five in the vicinity of Tracy, California.jpg",
            "imagerepository":"local",
            "imageinfo":[
               {
                  "timestamp":"2016-06-01T22:33:46Z",
                  "user":"Adam Cuerden",
                  "url":"https://upload.wikimedia.org/wikipedia/commons/9/91/%22Broke%2C_baby_sick%2C_and_car_trouble%21%22_-_Dorothea_Lange%27s_photo_of_a_Missouri_family_of_five_in_the_vicinity_of_Tracy%2C_California.jpg",
                  "descriptionurl":"https://commons.wikimedia.org/wiki/File:%22Broke,_baby_sick,_and_car_trouble!%22_-_Dorothea_Lange%27s_photo_of_a_Missouri_family_of_five_in_the_vicinity_of_Tracy,_California.jpg",
                  "descriptionshorturl":"https://commons.wikimedia.org/w/index.php?curid=49179423"
               }
            ]
         },

         ...

      }
   }
}
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109

1 Answers1

0

you may lookup this question: How to fetch data from an URL in Android?

If you successfully fetched the JSON content of your remote service, you'll probably want to traverse through the nodes of that JSON object to find the data you're interested in and put them into an Array or List you build up using that received data by yourself.

Janos Vinceller
  • 1,208
  • 11
  • 25