gpt4 book ai didi

java - 错误 : method onEnable does not override or implement a method from a supertype

转载 作者:行者123 更新时间:2023-11-30 02:43:25 42 4
gpt4 key购买 nike

我无法构建我的应用程序,因为我遇到了这个错误:

Error:(117, 5) error: method does not override or implement a method from a supertype.

我正在尝试做一个从 AppWidgetProvider 扩展的类,但我无法覆盖 onEnable 方法

@Override
public void onEnable(Context context) {

Log.e(LOGTAG, "Se ha activado onEnable");
super.onEnabled(context);
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, 1);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 10000 , createClockTickIntent(context));

}

最佳答案

要覆盖父类(super class)的方法,您应该使用相同的方法和参数名称

 @Override
public void onEnabled(Context context) {
//your code
}

关于java - 错误 : method onEnable does not override or implement a method from a supertype,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25450901/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com