I have some problem with eclipse android.
I have some java files, but if I call a method after return; (see the example) it tells me to remove the method. Why? I’m using Android 1.6.
public void onClick(View paramView)
{
switch (paramView.getId())
{
default:
case 2131296257:
}
while (true)
{
return;
fetchAlarmSettings(); <-- It tells me to remove this.
if (this.strAlarmOnOff.equals("0"))
{
this.butAlarmSet.setText("Turn Alarm Off");
this.db.updateSetting("alarmTime", this.strHour.concat(this.strMinute));
this.db.updateSetting("alarmOnOff", "1");
switch (this.cal.compareTo(Calendar.getInstance()))
{
default:
case -1:
}
while (true)
{
this.setNotifications.setAlarm(this.cal);
break;
this.cal.roll(5, 1);
}
}
this.butAlarmSet.setText("Turn Alarm On");
this.db.updateSetting("alarmOnOff", "0");
this.setNotifications.turnAlarmOff();
}
}
Thanks!
Your method will stop running the moment that the
returnstatement is hit. Basically it should give you an ‘Unreachable code!‘ warning, since any code after the return statement will never be executed. Removing thereturnkeyword should fix the problem.So basically Eclipse is telling you to remove the next line after the
returnsince it will never be executed. If you remove the method call it will complain over what ever line you throw in next.Besides that, there are other (according to me) flaws with your code… having a
while(true)loop without a break condition in this case seems odd (but then again I might be wrong here). Also, thedefaultblock is usually found at the end of a series ofcasestatements. Your secondwhile(true)loop will only iterate once since once thethis.setNotifications.setAlarm(this.cal);is executed the loop will stop iterating due to thebreakstatement.