Android Upload Image Using Retrofit Library Part 1 || Upload Image to Server

 

In continuation to previous tutorial we will be dealing with client side i.e., android app development using the fields specified in the database.

Add retrofit to your project

 

activity_main.xml

Create a simple UI, so that a user can select a image and the selected image is displayed using a image view also allow user to give a name for the image so that we can save image with the name.

 

 

ApiClient.java

Create a retrofit api client and specify the Base url, Retrofit configurations.

 

ApiInterface.java

Api interface with the post parameters include key values.

 

 

Img_Pojo.java

A Pojo file for handling key values and response from the server.

 

 

MainActivity.java

 

Initialize all the views a

 

 

Select image from the gallery

 

Convert the selected image

 

 

After selecting image bind it to image view using onActivityResult

 

finally upload the image and fetch the response

 

 

Full code

 

AndroidManifest.xml

Declare internet permission in manifest file

 

 

Output

Show Buttons
Hide Buttons
Read previous post:
Android Upload Image Using Retrofit Library Part 1 || Upload Image to Server

Close