0

I am developing an android application. I need to load images from a java server to Android Recyclerview or Listview.

I understand the android side of things via this thread http://www.androidhive.info/2014/06/android-facebook-like-custom-listview-feed-using-volley/.

I need help with the Java Server side.I need to retrive Images via JSON array. like this

 {
    "feed": [
    {
        "id": 1,
        "name": "National Geographic Channel",
        "image": "http://api.androidhive.info/feed/img/cosmos.jpg",
        "status": "\"Science is a beautiful and emotional human endeavor,\" says Brannon Braga, executive producer and director. \"And Cosmos is all about making science an experience.\"",
        "profilePic": "http://api.androidhive.info/feed/img/nat.jpg",
        "timeStamp": "1403375851930",
        "url": null
    },
    {
        "id": 2,
        "name": "TIME",
        "image": "http://api.androidhive.info/feed/img/time_best.jpg",
        "status": "30 years of Cirque du Soleil's best photos",
        "profilePic": "http://api.androidhive.info/feed/img/time.png",
        "timeStamp": "1403375851930",
        "url": "http://ti.me/1qW8MLB"
    },
    {
        "id": 5,
        "name": "Abraham Lincoln",
        "image": null,
        "status": "That some achieve great success, is proof to all that others can achieve it as well",
        "profilePic": "http://api.androidhive.info/feed/img/lincoln.jpg",
        "timeStamp": "1403375851930",
        "url": null
    },
    {
        "id": 3,
        "name": "Discovery",
        "image": "http://api.androidhive.info/feed/img/discovery_mos.jpg",
        "status": "A team of Austrian scientists has developed a laser system that causes fruit flies to dance.",
        "profilePic": "http://api.androidhive.info/feed/img/discovery.jpg",
        "timeStamp": "1403375851930",
        "url": "http://dsc.tv/xmMxD"
    },
    {
        "id": 4,
        "name": "Ravi Tamada",
        "image": "http://api.androidhive.info/feed/img/nav_drawer.jpg",
        "status": "Android Sliding Menu using Navigation Drawer",
        "profilePic": "http://api.androidhive.info/feed/img/ravi_tamada.jpg",
        "timeStamp": "1403375851930",
        "url": "http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/"
    },
    {
        "id": 6,
        "name": "KTM",
        "image": "http://api.androidhive.info/feed/img/ktm_1290.jpg",
        "status": "\"The Beast\" KTM 1290 Super Duke",
        "profilePic": "http://api.androidhive.info/feed/img/ktm.png",
        "timeStamp": "1403375851930",
        "url": ""
    },
    {
        "id": 7,
        "name": "Harley-Davidson",
        "image": "http://api.androidhive.info/feed/img/harley_bike.jpg",
        "status": "We’re assembling riders of every style, bike, and passion. If you ride with conviction, ride with us. You have 24 days to get ready for World Ride. Prepare by visiting:",
        "profilePic": "http://api.androidhive.info/feed/img/harley.jpg",
        "timeStamp": "1403375851930",
        "url": "http://bit.ly/1wmBWaN"
    },
    {
        "id": 8,
        "name": "Rock & Girl",
        "image": "http://api.androidhive.info/feed/img/rock.jpg",
        "status": "A long time back...",
        "profilePic": "http://api.androidhive.info/feed/img/rock_girl.jpg",
        "timeStamp": "1403375851930",
        "url": ""
    },
    {
        "id": 8,
        "name": "Gandhi",
        "image": null,
        "status": "An eye for an eye will make the whole world blind.",
        "profilePic": "http://api.androidhive.info/feed/img/gandhi.jpg",
        "timeStamp": "1403375851930",
        "url": ""
    },
    {
        "id": 9,
        "name": "LIFE",
        "image": "http://api.androidhive.info/feed/img/life_photo.jpg",
        "status": "In 1965, LIFE photographer Bill Ray spent weeks with the Hells Angels, but his amazing photos never ran in the magazine",
        "profilePic": "http://api.androidhive.info/feed/img/life.jpg",
        "timeStamp": "1403375851930",
        "url": "http://ti.me/1rfcQa4"
    },
    {
        "id": 10,
        "name": "Shakira",
        "image": "http://api.androidhive.info/feed/img/shakira_la_la.png",
        "status": "Download La La La (Brazil 2014) from iTunes:",
        "profilePic": "http://api.androidhive.info/feed/img/shakira.jpg",
        "timeStamp": "1403375851930",
        "url": "http://smarturl.it/FWCalbum?IQid=sh"
    },
    {
        "id": 11,
        "name": "A. R. rahman",
        "image": "http://api.androidhive.info/feed/img/ar_bw.jpg",
        "status": "",
        "profilePic": "http://api.androidhive.info/feed/img/ar.jpg",
        "timeStamp": "1403375851930",
        "url": ""
    }
]
}

and how to get the Image url in from server side like this enter image description here

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Arya
  • 1,729
  • 3
  • 17
  • 35

1 Answers1

0

You can used picasso library.

Picasso.with(context).load("http://api.androidhive.info/feed/img/cosmos.jpg").placeholder(R.drawable.no_image).into(imageView);

Patel Hiren
  • 305
  • 2
  • 11
  • I am getting android side code. I need to develop code in server side. how to get url like http://api.androidhive.info/feed/img/cosmos.jpg in java server – Arya Aug 31 '15 at 09:06
  • Hello Arya, u have problem with how to get server image path then store images server path in your database and return it into the webservice – Amol Sawant Aug 31 '15 at 09:09
  • try { JSONObject jsonObject = new JSONObject("ResponseString"); JSONArray array = jsonObject.getJSONArray("feed"); for (int i = 0; i < array.length(); i++) { JSONObject jsonObject2 = array.getJSONObject(i); String URL = jsonObject2.getString("image"); } } catch (JSONException e) { e.printStackTrace(); } – Patel Hiren Aug 31 '15 at 09:17