StackAsk is a community where developers ask questions, share answers and learn from each others real-world experience, so every solved problem helps the next person who runs into it.
btn_start.setOnClickListener(view -> { if (txt_cms_address.getText() != null) { cmsAddress = txt_cms_address.getText().toString(); Log.d(TAG, "CMS" + cmsAddress); APIRegisterDisplay(); // APISchedule(); // APIGetRequiredFile(); if (checkConnect) { // APIGetRequiredFile(); // APISchedule(); Log.d(TAG, "check ok"); } else { Log.d(TAG, "check k ok"); } } else { Toast.makeText(this, "Address must not be empty!!", Toast.LENGTH_SHORT).show(); } });
checkConnect == true
if(checkConnect)
if (display != null)
private void APIRegisterDisplay() { RegisterDisplay registerDisplay = new RegisterDisplay(abc, xyz ...); apiService = RetrofitClient.getClient(cmsAddress).create(APIService.class); apiService.Register(registerDisplay).enqueue(new Callback() { @Override public void onResponse(@NonNull Call call, @NonNull Response response) { if (response.isSuccessful()) { assert response.body() != null; JsonObject json = response.body().getAsJsonObject("response").getAsJsonObject("display").getAsJsonObject("$"); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String string = gson.toJson(json); Display display = gson.fromJson(string, Display.class); if (display != null) { if (display.getCode().equals("0")) { //code == 0 Display is active and ready to start Toast.makeText(getApplicationContext(), display.getMessage(), Toast.LENGTH_SHORT).show(); Log.d(TAG, "get display successful"); checkConnect = true; } else { Toast.makeText(getApplicationContext(), display.getMessage(), Toast.LENGTH_SHORT).show(); } } else { Log.d(TAG, "failed"); Toast.makeText(getApplicationContext(), "Unable to connect to CMS!!", Toast.LENGTH_SHORT).show(); } } } @Override public void onFailure(@NonNull Call call, @NonNull Throwable t) { Log.e(TAG, "REGISTER_DISPLAY:" + t.getLocalizedMessage()); } }); }
checkConnect
display.getCode()
2.2K Point(s)
1.2K Point(s)
313 Point(s)
178 Point(s)
138 Point(s)
Your account is signed in on the device(s) below. Sign out of at least one of them to continue signing in on this device.
Your account is signed in on the device(s) below. Sign out directly on one of those devices, or wait until the sign-in again time shown below.
If you cant access those devices, please contact the administrator to sign them out for you.
Input your email to receive reset password link, or if you remember your password, you can click