问题:
我试图通过 sharedpreferences 提取布尔值,但是每次我尝试使用该值时,我都会收到一个编译器错误,指出该运算符对于参数类型是未定义的。我不确定为什么会发生这种情况 - 我相信我已经将时间布尔值转换为字符串 - 然后我应该能够将其用作乘以得到我的时间值的值:
资源:
String PREF = "prefs";
SharedPreferences prefs = getSharedPreferences(PREF, Context.MODE_PRIVATE);
boolean name = prefs.getBoolean("name", true);
boolean code = prefs.getBoolean("corename", true);
boolean time = prefs.getBoolean("time", true);
boolean ssid = prefs.getBoolean("restricted", true);
String killtime = String.valueOf(time);
Intent intent2 = new Intent(Rules.this, KillTimer.class);
PendingIntent pintent2 = PendingIntent.getActivity(Rules.this, 0, intent2,
0);
AlarmManager alarm2 = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
killtime * 1000, pintent2); // error is thrown here