Recent Posts

Site Creator




Day 7 : Making A Get Request in Android

Posted on

Dear Friends




Lets play with Networking in Android.

Important rule :

Every network transaction  should only be done on a worker thread. 

I think above line is worth repeating Every network transaction  should only be done on a worker thread. 

Now the question is why ?

Fetching data from network is a long running operation that could block your UI Thread if you try to make network calls on UI Thread. Thus increasing user frustration and sluggishness of your app. Also some of functionalities might break in between.

There is an array of problems those may result in network transaction is done on UI Thread. So like a good OS android , in newer version android doesn’t allow developers to make network call on UI Thread.

Here we are making a Get request to fetch some data from Network using a worker thread.


So what we have to do.

Create an activity and then use worker thread instance to execute GET Request.

So somewhere in onCreate of your activity



Inside below method


we get response from server. Response String will be having null, empty , success response.

Few important points

  1. To make network calls in android, application should have Network permission.


2. onPostExecute method is execute in UI thread. so there is not need of handler mechanism here to communicate with UI thread.



Homework : At last but not the least , create an android application that can fetch an image from network and show it in UI.





Happy Coding.















Disclaimer: The aforesaid writeup by Relsell Global writer is for the general understanding of the readers. It does not render any professional advice or opinion.


Leave a Reply

Your email address will not be published. Required fields are marked *