An open API service indexing awesome lists of open source software.

https://github.com/bhattaraisubash/jsonfetch

Fetch Json From URL and show them using list view.
https://github.com/bhattaraisubash/jsonfetch

android java xml

Last synced: about 2 months ago
JSON representation

Fetch Json From URL and show them using list view.

Awesome Lists containing this project

README

          

This sample app can fetch json from url and show them in list view using built-in Java & Android Methods .

In this app , I have used Java's URL and
HttpURLConnection
to get Input Stream from given url
and JSONArray
and JSONObjectto fetch JSON .

Procedures:



  • Give Internet Permission at
    AndroidManifest.xml


  • android.permission.INTERNET
  • Create Post Entity »

    Post.java


  • Create A Adapter For List View »

    ListAdapter.java


    public class ListAdapter extends ArrayAdapter {
    ...


  • Create a inner class JsonFetch.java in

    MainActivity.java
    which extends AsyncTask.

    private class FetJson extends AsyncTask> {
    ...


    In onPostExecute(..) method , adapter is set for listView .

  • Now Execute JsonFetch class inside onCreate method of

    MainActivity.java
    passing url as parameter.


    new FetJson().execute("https://jsonplaceholder.typicode.com/posts");



Finally list view shows available data .