@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(Tb.isChecked()){
android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals("120000");
}else{
android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals("300000");
}
}
I'm developing a widget which has the option for getting updates every 2 min and 30 min. so I made a toggle button to switch between time. The above block of code I'm using to enable the Toggle button known as Tb. The app is not showing errors, but it doesn't seem to be working. Can somebody check my code for errors.
This code is not setting anything.
You are testing ACTION_APPWIDGET_UPDATE
to see if it is equal to "120000" or "300000". ACTION_APPWIDGET_UPDATE
is a String constant that is always equal to "android.appwidget.action.APPWIDGET_UPDATE".
Therefore, each of those lines do nothing and the equals()
test which is not evaluated always returns false
.
Good news is that the following lines of code are probably getting correctly triggered, they just are not the correct way to set interval values:
android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals("120000");
android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals("300000");
To fix this problem, find another way to set your 2 minute and 30 minute interval values.