此应用程序正在运行。但我不明白为什么我会收到那个警告。我希望你能提供一个解决方案。谢谢!
java代码:
/*final int*/ mId = (int) System.currentTimeMillis();
i.putExtra("com.somitsolutions.android.smsscheduler.id", mId);
AlarmManager am = (AlarmManager)
getApplicationContext().getSystemService(getApplicationContext().ALARM_SERVICE); <<-- this is where i get the warning
PendingIntent pi = PendingIntent.getService(getApplicationContext(), mId, i, PendingIntent.FLAG_UPDATE_CURRENT);
顺便说一句,我是初学者,所以我不确定这些代码是否能帮助您理解和回答。 :)
最佳答案
replace
getApplicationContext().ALARM_SERVICE
with
Context.ALARM_SERVICE
您正在尝试使用不正确的 Context 实例访问 Context 类中存在的静态字段。
关于java - 应该以静态方式访问静态字段 Context.ALARM_SERVICE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22485467/