I wanna upload a file with retrofit which has a progress bar which shows the progress percentage and I wanna send some parameters by post method How can I do that?
Asked
Active
Viewed 1,804 times
2 Answers
1
If you are using Retrofit 2, maybe you could find this answer helpful Is it possible to show progress bar when upload image via Retrofit 2

Gabriella Angelova
- 2,985
- 1
- 17
- 30
0
first of yore java file in upload pic call in ....progress bar initiation...
-----------------------------------------------------
SignUp.this.findViewById(R.id.progress_bar).setVisibility(View.VISIBLE);
Call<UploadPhoto> call = apiService.uploadFile(fileToUpload, filename, api, user_email);
call.enqueue(new Callback<UploadPhoto>() {
@Override
public void onResponse(Call<UploadPhoto> call, Response<UploadPhoto> response) {
SignUp.this.findViewById(R.id.progress_bar).setVisibility(View.GONE);
UploadPhoto inquiryResponse = response.body();
if (inquiryResponse.getStatus().equals("1")) {
} else {
}
}
@Override
public void onFailure(Call<UploadPhoto> call, Throwable t) {
}
});
-----------------------------------------------------------
and then creat xml file : >> progress_uploading_layout.xml
--------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:visibility="gone"
android:background="@android:color/transparent"
android:orientation="vertical">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/uploading"
android:textColor="@color/green"
android:textSize="20sp" />
</LinearLayout>
-----------------mention your activity----
as put your activity_main as xml file ..
<include layout="@layout/progress_uploading_layout"/>

Nirmal Vaghasiya
- 31
- 7