0

我正在使用应用内更新,但它在生产中不起作用。我尝试了各种方法,但无法解决问题。代码在java for android studio project 我的代码如下: -

    private void checkUpdate() {

        Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();

        appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {

            if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
                    && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
                Toast.makeText(getApplicationContext(), "Update available", Toast.LENGTH_LONG).show();
                startUpdateFlow(appUpdateInfo);
            } else if  (appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS){
                Toast.makeText(getApplicationContext(), "Reached 2..  ", Toast.LENGTH_LONG).show();
                startUpdateFlow(appUpdateInfo);
            } else if (appUpdateInfo.updateAvailability()==UpdateAvailability.UPDATE_NOT_AVAILABLE){
                Toast.makeText(getApplicationContext(), "Update unavailable", Toast.LENGTH_LONG).show();
                Intent intent = new Intent(getApplicationContext(), StartActivity.class);
                startActivity(intent);
                finish();
            }
        });
    }
    ```

Please tell me what is the mistake I am doing

4

0 回答 0