You are on page 1of 2

listview

movieNmesListview
progressbar
permission=android manifes
permission acessnetwork=tell whether connected or not
.intenet for internet connection
method
setcontent==show content or hide content
isconnetcted=for checking wherther connected to interbnte or not
isconnetcted
{
ConnectivityManger manger=(ConnectivityManger)
getSystemservice(Context.Connectivity_Service);
NetworkInfo networkInfo = manger.getActiveNetworkInfo();
if(networkinfo!=null)
{
return networkInfo.isConnectedOrConnecting();
}
else
{
return false;
}
}
}
fething response from server in new thread
new Thread()
{
public void run()
{
Url url = new Url(movieurl);
HttpUrlConnection.connection =(HttpUrlConnection)url.openConnection();
connection.connect();
int code = connection.getResponseCode();
if(code==HttpUrlConnection.HTTP_OK)
{
InputStream stream = connection.getInputStream();
String response = fromInputStream(stream);
Log.i("vipul",response);
}
}
catch(IOException e)
{
e.printTracktace();
}
}.start();
Parsing Json Response
private void parseMovieJson(String response) throws JsonException
{
JSONArray movieArray = new JSONArray(response);
List<String> movieTitle = new ArrayList<>();
for(int i =0;i<movieArray.lenght();i++)
{
JSONOBJECT Object = moviewArray.getJsonObject(i);
JsonObject movieobject = object.getJsonObject("movie");
string movietitle =movieObject.getString("tiltle");
String movieTitle.add(movieTitle);
}

populateListView(movieTitkes)
}

You might also like