我正在尝试制作一个检查一年中日期的应用程序。每当我声明一个大于某个数字的数组时,我都会收到停止响应消息。我应该怎么办?
public class Main extends Activity {
int[] payDays = new int[11];
int dayOfYear;
Calendar cal;
Intent goToSales, goToChains, goToCheck, goToReference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
cal = Calendar.getInstance();
dayOfYear = cal.get(Calendar.DAY_OF_YEAR);
payDays = new int[11];
payDays[0] = 60;
payDays[1] = 88;
payDays[2] = 123;
payDays[3] = 151;
payDays[4] = 179;
payDays[5] = 214;
payDays[6] = 242;
payDays[7] = 270;
payDays[8] = 305;
payDays[9] = 333;
payDays[10] = 361;
payDays[11] = 31;
// Phew! Checks when to send the notification
if (dayOfYear == payDays[0] ||
dayOfYear == payDays[1] ||
dayOfYear == payDays[2] ||
dayOfYear == payDays[3] ||
dayOfYear == payDays[4] ||
dayOfYear == payDays[5] ||
dayOfYear == payDays[6] ||
dayOfYear == payDays[7] ||
dayOfYear == payDays[8] ||
dayOfYear == payDays[9] ||
dayOfYear == payDays[10] ||
dayOfYear == payDays[11])
{
Notification noti = new Notification.Builder(this)
.setContentTitle("MCHelper")
.setContentText("It's the end of the year!")
.setSmallIcon(R.drawable.notify2).build();
noti.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager notiMan = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notiMan.notify(0, noti);
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}