Efiicient way to show 'Cant access network' View with 'Retry' and additional options like 'Wifi Settings', 'Mobile Network'

前端 未结 2 482
孤街浪徒
孤街浪徒 2021-02-02 04:46

I need to include this in my app

When should it get triggered?

  • Any action triggered by user from UI requires internet
2条回答
  •  北海茫月
    2021-02-02 05:15

    Volley DETROYS all listeners as soon as it receives something from the server, regardless of whether the response is a proper response or an error response.

    A request needs to constructed everytime it should be sent or resent.

    These steps will help achieve it

    • Create a fragment with Retry and other necessary buttons like Wifi Settings, Mobile Network Settings
    • Create a full sized FrameLayout inside RelativeLayout on necessary views to accommodate the fragment created and hide it initially
    • When request fails, make the FrameLayout visible and the retry button should call the function that constructs and calls the request

提交回复
热议问题