0

I am writing an Android App and I am trying to Login to the system , but the Loading Dialog Tack a lot time to disappear Although the system has completed the Login process . How to set session timeout fro the Login process ??

Thank.

3 Answers3

2

Try this .

Set timeout in your code .

HttpURLConnection

HttpURLConnection connection = (HttpURLConnection)url.openConnection();
// edit here ,change time
connection.setConnectTimeout(20000);
connection.setReadTimeout(20000);

OKHttp

private final OkHttpClient client;

public ConfigureTimeouts() throws Exception {
    client = new OkHttpClient.Builder()
        .connectTimeout(100, TimeUnit.SECONDS)
        .writeTimeout(100, TimeUnit.SECONDS)
        .readTimeout(100, TimeUnit.SECONDS)
        .build();
} 
KeLiuyue
  • 8,149
  • 4
  • 25
  • 42
0

As this post applied it. you can try this:

public void timerDelayRemoveDialog(long time, final Dialog d){
    new Handler().postDelayed(new Runnable() {
        public void run() {                
            d.dismiss();         
        }
    }, time); 
}
Orvenito
  • 437
  • 2
  • 14
0

Create a andler and dismiss the dialog inside post delayed method.

 new Handler().postDelayed(new Runnable() {
    public void run() {                
        dialog_obj.dismiss();         
    }
}, 6000); 

this code will dismiss the dialog after 6 seconds.

Saneesh
  • 1,796
  • 16
  • 23