How to show a popup message after 1 min that any response is not coming from a server?

44
January 11, 2019, at 10:50 PM

In below code, I am getting the response from a server, before getting the response from the server, I am giving 1 min timer to get the response.

Suppose after 1 min still I am not getting any response from the server or something went wrong means want to show popup message "Invalid details".

Now, want to after 1 min, not response wrong also want to show a popup message

can anyone help me

final ProgressDialog progressDialog = new ProgressDialog(LoginActivity.this);
        progressDialog.setIndeterminate(true);
        progressDialog.setMessage("Authenticating..." + 60000 / 1000 + " Second(s)");
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setCancelable(false);
        progressDialog.setIndeterminate(true);
        new CountDownTimer(60000, 1000) {
            public void onTick(long millisUntilFinished) {
                // You don't need anything here
                progressDialog.setMessage("Please wait...." + millisUntilFinished / 1000 + " Second(s)");
                if (!progressDialog.isShowing())
                    progressDialog.show();
            }
            public void onFinish() {
                if (progressDialog.isShowing())
                    progressDialog.dismiss();
            }
        }.start();

        API1 service = retrofit.create(API1.class);
        Call<Login> call = service.authenticate(this.emailId, password);
        Log.i(TAG, "Sending---" + url + service + url + "\n" + "emailId:" + emailId + "\n" + "password:" + password );
        call.enqueue(new Callback<Login>() {
            @Override
            public void onResponse(Call<Login> call, Response<Login> response) {
// String status=response.body().getStatus().toString();
                progressDialog.dismiss();
                if (response.isSuccessful()) {
// showResponse(response.body().toString());
                    String status=response.body().getStatus().toString();
                    if(status.equals("success")){
                        if (progressDialog != null)
                            Toast.makeText(LoginActivity.this, "Login successfully", Toast.LENGTH_SHORT).show();
                        Intent mainIntent;
                        mainIntent = new Intent(LoginActivity.this, DeviceControlActivity.class);
                        startActivity(mainIntent);
                        finish();
                    }
                }
                else{
                    Toast.makeText(LoginActivity.this, "Invalid EmailId and password", Toast.LENGTH_SHORT).show();
//
                }
            }
            @Override
            public void onFailure(Call<Login> call, Throwable t) {
                Log.e(TAG, "Unable to submit post to API.");
                progressDialog.dismiss();
            }
        });
    }
READ ALSO
The application does not install a second time

The application does not install a second time

I sign the APK, I choose the type of Debug, I distribute it directly, I will not upload it to Google Play

32
How do you debug android platform source code?

How do you debug android platform source code?

When you have issues with android source code, how do you dig into the code? For example for this issue I saw from the debugger that the CookieManager is AwCookieManagerSo from Google search I found that the setCookie is the following:

49
How to limit multiple image selection from the gallery?

How to limit multiple image selection from the gallery?

I have implemented adding multiple image selection from the gallery in my projectHowever, I want to limit the user so he/she can select only 3 images from the gallery

12
How to put image on google map using groundoverlay in android where image having 5k (width)* 5k (height) and 1.6 mb of size?

How to put image on google map using groundoverlay in android where image having 5k (width)* 5k (height) and 1.6 mb of size?

I wanna put an image of my city which contains roads and homes on google map using groundoverlay method in android, where my image size and dimensions are very largeHow I can put this image on map in android?

21