Reputation: 12837
I have check against a boolean value if(!updating_questions) that is not working in my intent service in the following method
private void sendBroadcast(Context context, String key, String value){
//Don't broadcast if updating questions
Util.log_debug_message("@@@@ Updating questions - " + updating_questions);
if(!updating_questions){
Util.log_debug_message("@@@@ Broadcasting, updating_questions = " + updating_questions);
Broadcast.sendBroadcast(context, ResponseReceiver.ACTION_RESP, Intent.CATEGORY_DEFAULT,
key, value);
}
}
The updating_questions flag is a global private variable and it's value is false
private boolean updating_questions = false;
The value is set from an extra in the onHandleIntent(Intent intent) method
updating_questions = intent.getBooleanExtra(AppConstants.C2DM_MESSAGE_UPDATE_QUESTIONS, false);
The value is set using
if(updating_questions){
refreshService.putExtra(AppConstants.C2DM_MESSAGE_UPDATE_QUESTIONS, true);
} else {
refreshService.putExtra(AppConstants.C2DM_MESSAGE_UPDATE_QUESTIONS, false);
}
This check seems to be behaing itslef properly and the output in the console shows that the value is false but the condition is being treated as if it true
D/QuizApp ( 878): @@@@ Updating questions - false
D/QuizApp ( 878): @@@@ Broadcasting, updating_questions = false
So if the value is false how is it possible to be broadcasting the message? I'm obviously missing something really fundamental but haven't a clue what it is
Upvotes: 0
Views: 7088
Reputation: 87064
Your if
condition is:
!updating_questions
This means that do this block if updating_questions
is NOT true
(see the !
operator).
Upvotes: 3