java - CountDownTimer 类中的构造函数 CountDownTimer 无法应用于给定类型

标签 java android

我收到以下错误:

Error:(104, 51) error: constructor CountDownTimer in class CountDownTimer cannot be applied to given types;
    required: long,long
    found: no arguments
    reason: actual and formal argument lists differ in length

这是我的代码:

class C06964 extends CountDownTimer {

    /* renamed from: com.aplikasi.gokil.MyActivity.4.1 */
    class C06941 extends CountDownTimer {
        final /* synthetic */ Toast val$toast;

        C06941(long x0, long x1, Toast toast) {
            this.val$toast = toast;
            super(x0, x1);
        }

        public void onTick(long millisUntilFinished) {
            this.val$toast.show();
        }

        public void onFinish() {
            this.val$toast.cancel();
        }
    }

    /* renamed from: com.aplikasi.gokil.MyActivity.4.2 */
    class C06952 extends CountDownTimer {
        final /* synthetic */ Toast val$toast;

        C06952(long x0, long x1, Toast toast) {
            this.val$toast = toast;
            super(x0, x1);
        }

        public void onTick(long millisUntilFinished) {
            this.val$toast.show();
        }

        public void onFinish() {
            this.val$toast.cancel();
            MyActivity.this.startActivity(IntentCompat.makeRestartActivityTask(MyActivity.this.getPackageManager().getLaunchIntentForPackage(MyActivity.this.getPackageName()).getComponent()));
            System.exit(0);
        }
    }

    C06964(long x0, long x1) {
        super(x0, x1);
    }

    public void onTick(long millisUntilFinished) {
        ((TextView) MyActivity.this.findViewById(id.textView)).setText("Restart Application In : " + (millisUntilFinished / 1000));
        Toast toast = Toast.makeText(MyActivity.this.getBaseContext(), "Restart Application In : " + (millisUntilFinished / 1000), 0);
        toast.show();
        new C06941(1000, 1000, toast).start();
    }

    public void onFinish() {
        Toast toast = Toast.makeText(MyActivity.this.getBaseContext(), "Restarting Application...", 0);
        toast.show();
        ((TextView) MyActivity.this.findViewById(id.textView)).setText("Restarting Application...");
        new C06952(3000, 3000, toast).start();
    }
}

有人可以解释一下为什么我收到此错误吗?

最佳答案

Invocation of a superclass constructor must be the first line in the subclass constructor. - Using the Keyword super

您的构造函数在设置 this.val$toast = toast 后调用 super(x0, x1)

关于java - CountDownTimer 类中的构造函数 CountDownTimer 无法应用于给定类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38535513/

相关文章:

Android move 按钮

android - Android Studio 中的产品 flavor

android - Android SDK 中的命名约定

java - 如何点击左侧菜单项

Java:在继续其余方法之前部署一种方法

java - 以给定的执行时间启动线程

android - 找不到要导入的项目

android - 构建适用于室内建筑的 Android map 应用程序

java - 添加新数据后 ComboBox 数据库值不会刷新

javascript - 使用后端的值在 extjs 中动态设置日期