Code example for LinkedBlockingDeque

Methods: add

0
		int retValue = super.onStartCommand(intent, flags, startId);
 
        mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
		if (checkPreferences()) { 
            if (mMessages == null) {
                mMessages = new LinkedBlockingDeque<String>();
            } 
 
			String message = "";
			try { 
				message = buildNotificationString(intent.getStringExtra("originatingAddress"), intent.getStringExtra("messageBody"));
			} catch (NullPointerException e) {
				//error in getting Intent's extra strings, cannot continue 
				return retValue;
			} 
            mMessages.add(message);
            Log.v(TAG, "Added message to queue");
 
            if (mTts == null) {
                Log.v(TAG, "Creating new TTS");
                mTts = new TextToSpeech(this, this);