1

I am showing a prgressbar when volley request is going on and hiding progressbar inside onError and onResponse callback

Inside onStop method of activity I am calling cancelAll(TAG)

But issue is if network request is going on and someone hits lock screen onStop is called and request gets cancelled but since there is no call back for it I am unable to update UI and activity keeps showing progressbar.

There has to be a callback for it.

Does anyone has solution on it.

How can I update my UI if request is cancelled.

I want to hide progressbar and show a retry button once request is cancelled how can I achieve that

amodkanthe
  • 4,345
  • 6
  • 36
  • 77

2 Answers2

0

When someone hits Lock Screen the configuration changes and the activity is recreated. You can prevent the screen to lock (Another question with the answer), or you can update the UI with the onResume() method, who is called when the activity return from lock screen.

Community
  • 1
  • 1
0

I have created a library that provide the callback even after cancellation

Fast Android Networking is the best for network calls.

Android Networking is a powerful library for doing any type of networking in Android applications which is made on top of OkHttp Networking Layer.

Android Networking takes care of each and everything. So you don't have to do anything, just make request and listen for the response.

Android Networking supports:

All type of HTTP/HTTPS request like GET,POST,etc Downloading any type of file Uploading any type of file (supports multipart upload) Cancelling a request Setting priority to any request (LOW, MEDIUM, HIGH, IMMEDIATE) As it uses OkHttp as a networking layer, it supports:

HTTP/2 support allows all requests to the same host to share a socket Connection pooling reduces request latency (if HTTP/2 isn’t available) Transparent GZIP shrinks download sizes Response caching avoids the network completely for repeat requests Fast Android Networking Link

Amit Shekhar
  • 3,135
  • 2
  • 16
  • 17