Example usage for android.media AudioManager STREAM_NOTIFICATION

List of usage examples for android.media AudioManager STREAM_NOTIFICATION

Introduction

In this page you can find the example usage for android.media AudioManager STREAM_NOTIFICATION.

Prototype

int STREAM_NOTIFICATION

To view the source code for android.media AudioManager STREAM_NOTIFICATION.

Click Source Link

Document

Used to identify the volume of audio streams for notifications

Usage

From source file:com.trellmor.berrytubechat.ChatActivity.java

private void loadPreferences() {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    try {/*w  w w.  j  a v a2 s .c  o m*/
        mScrollback = Integer.parseInt(settings.getString(MainActivity.KEY_SCROLLBACK, "100"));
    } catch (NumberFormatException e) {
        mScrollback = 100;
    }

    if (mScrollback <= 0)
        mScrollback = 100;

    if (mBinder != null)
        mBinder.getService().setChatMsgBufferSize(mScrollback);

    try {
        mFlair = Integer.parseInt(settings.getString(MainActivity.KEY_FLAIR, "0"));
    } catch (NumberFormatException e) {
        mFlair = 0;
    }

    if (settings.getBoolean(MainActivity.KEY_SQUEE, false)) {
        mNotification = new NotificationCompat.Builder(this);
        mNotification.setSmallIcon(R.drawable.ic_stat_notify_chat);
        mNotification.setLights(0xFF0000FF, 100, 2000);
        mNotification.setAutoCancel(true);

        Intent intent = new Intent(this, ChatActivity.class);
        intent.putExtra(MainActivity.KEY_USERNAME, mUsername);
        intent.putExtra(MainActivity.KEY_PASSWORD, mPassword);
        intent.setAction(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP
                | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY);

        mNotification.setContentIntent(
                PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
        String squee = settings.getString(MainActivity.KEY_SQUEE_RINGTONE, "");
        if (!"".equals(squee)) {
            mNotification.setSound(Uri.parse(squee), AudioManager.STREAM_NOTIFICATION);
        }
        if (settings.getBoolean(MainActivity.KEY_SQUEE_VIBRATE, false)) {
            mNotification.setVibrate(new long[] { 0, 100 });
        }
    } else {
        mNotification = null;
    }

    boolean showVideo = settings.getBoolean(MainActivity.KEY_VIDEO, false);
    if (showVideo != mShowVideo) {
        // If the value has changed, act on it
        if (showVideo) {
            if (!mFirstPrefLoad) {
                Toast.makeText(this, R.string.toast_video_enabled, Toast.LENGTH_LONG).show();
            }
        } else {
            mBinder.getService().disableVideoMessages();
            setTextVideoVisible(false);
        }
    }
    mShowVideo = showVideo;

    mShowDrinkCount = settings.getBoolean(MainActivity.KEY_DRINKCOUNT, true);
    mPopupPoll = settings.getBoolean(MainActivity.KEY_POPUP_POLL, false);
    updateDrinkCount();

    mFirstPrefLoad = false;
}

From source file:org.smssecure.smssecure.notifications.MessageNotifier.java

private static void sendInThreadNotification(Context context, Recipients recipients) {
    if (!SilencePreferences.isInThreadNotifications(context)
            || ServiceUtil.getAudioManager(context).getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
        return;/* www.  j  a  va2 s.  c  o  m*/
    }

    Uri uri = recipients != null ? recipients.getRingtone() : null;

    if (uri == null) {
        String ringtone = SilencePreferences.getNotificationRingtone(context);

        if (ringtone == null) {
            Log.w(TAG, "ringtone preference was null.");
            return;
        }

        uri = Uri.parse(ringtone);

        if (uri == null) {
            Log.w(TAG, "couldn't parse ringtone uri " + ringtone);
            return;
        }
    }

    if (uri.toString().isEmpty()) {
        Log.d(TAG, "ringtone uri is empty");
        return;
    }

    Ringtone ringtone = RingtoneManager.getRingtone(context, uri);

    if (ringtone == null) {
        Log.w(TAG, "ringtone is null");
        return;
    }

    if (Build.VERSION.SDK_INT >= 21) {
        ringtone.setAudioAttributes(
                new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN)
                        .setUsage(AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT).build());
    } else {
        ringtone.setStreamType(AudioManager.STREAM_NOTIFICATION);
    }

    ringtone.play();
}

From source file:com.ferdi2005.secondgram.NotificationsController.java

protected void showSingleBackgroundNotification() {
    notificationsQueue.postRunnable(new Runnable() {
        @Override//w  ww.ja  v  a  2 s  .  c  o  m
        public void run() {
            try {
                if (!ApplicationLoader.mainInterfacePaused) {
                    return;
                }
                SharedPreferences preferences = ApplicationLoader.applicationContext
                        .getSharedPreferences("Notifications", Context.MODE_PRIVATE);

                boolean notifyDisabled = false;
                int needVibrate = 0;
                String choosenSoundPath = null;
                int ledColor = 0xff0000ff;
                int priority = 0;
                int vibrateOverride;

                if (!preferences.getBoolean("EnableAll", true)) {
                    notifyDisabled = true;
                }

                String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
                if (!notifyDisabled) {
                    vibrateOverride = 0;
                    choosenSoundPath = null;
                    boolean vibrateOnlyIfSilent = false;

                    if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) {
                        choosenSoundPath = null;
                    } else if (choosenSoundPath == null) {
                        choosenSoundPath = preferences.getString("GlobalSoundPath", defaultPath);
                    }
                    needVibrate = preferences.getInt("vibrate_messages", 0);
                    priority = preferences.getInt("priority_group", 1);
                    ledColor = preferences.getInt("MessagesLed", 0xff0000ff);

                    if (needVibrate == 4) {
                        vibrateOnlyIfSilent = true;
                        needVibrate = 0;
                    }
                    if (needVibrate == 2 && (vibrateOverride == 1 || vibrateOverride == 3)
                            || needVibrate != 2 && vibrateOverride == 2
                            || vibrateOverride != 0 && vibrateOverride != 4) {
                        needVibrate = vibrateOverride;
                    }
                    if (vibrateOnlyIfSilent && needVibrate != 2) {
                        try {
                            int mode = audioManager.getRingerMode();
                            if (mode != AudioManager.RINGER_MODE_SILENT
                                    && mode != AudioManager.RINGER_MODE_VIBRATE) {
                                needVibrate = 2;
                            }
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                    }
                }

                Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
                intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
                intent.setFlags(32768);

                PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0,
                        intent, PendingIntent.FLAG_ONE_SHOT);

                String name = LocaleController.getString("AppName", R.string.AppName);

                NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                        ApplicationLoader.applicationContext).setContentTitle(name)
                                .setSmallIcon(R.drawable.notification).setAutoCancel(true)
                                .setNumber(total_unread_count).setContentIntent(contentIntent)
                                .setGroup("messages").setGroupSummary(true).setColor(0xff2ca5e0);

                mBuilder.setCategory(NotificationCompat.CATEGORY_MESSAGE);

                String lastMessage = LocaleController.getString("YouHaveNewMessage",
                        R.string.YouHaveNewMessage);
                mBuilder.setContentText(lastMessage);
                mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(lastMessage));

                if (priority == 0) {
                    mBuilder.setPriority(NotificationCompat.PRIORITY_DEFAULT);
                } else if (priority == 1) {
                    mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
                } else if (priority == 2) {
                    mBuilder.setPriority(NotificationCompat.PRIORITY_MAX);
                }

                if (!notifyDisabled) {
                    if (lastMessage.length() > 100) {
                        lastMessage = lastMessage.substring(0, 100).replace('\n', ' ').trim() + "...";
                    }
                    mBuilder.setTicker(lastMessage);
                    if (choosenSoundPath != null && !choosenSoundPath.equals("NoSound")) {
                        if (choosenSoundPath.equals(defaultPath)) {
                            mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI,
                                    AudioManager.STREAM_NOTIFICATION);
                        } else {
                            mBuilder.setSound(Uri.parse(choosenSoundPath), AudioManager.STREAM_NOTIFICATION);
                        }
                    }
                    if (ledColor != 0) {
                        mBuilder.setLights(ledColor, 1000, 1000);
                    }
                    if (needVibrate == 2 || MediaController.getInstance().isRecordingAudio()) {
                        mBuilder.setVibrate(new long[] { 0, 0 });
                    } else if (needVibrate == 1) {
                        mBuilder.setVibrate(new long[] { 0, 100, 0, 100 });
                    } else if (needVibrate == 0 || needVibrate == 4) {
                        mBuilder.setDefaults(NotificationCompat.DEFAULT_VIBRATE);
                    } else if (needVibrate == 3) {
                        mBuilder.setVibrate(new long[] { 0, 1000 });
                    }
                } else {
                    mBuilder.setVibrate(new long[] { 0, 0 });
                }
                notificationManager.notify(1, mBuilder.build());
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    });
}

From source file:org.docrj.smartcard.reader.AppSelectActivity.java

private void initSoundPool() {
    synchronized (this) {
        if (mSoundPool == null) {
            mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
            mTapSound = mSoundPool.load(this, R.raw.tap, 1);
        }//ww  w.  j  a v  a  2 s.  co  m
    }
}

From source file:com.brq.wallet.activity.receive.ReceiveCoinsActivity.java

@Subscribe
public void syncStopped(SyncStopped event) {
    TextView tvRecv = (TextView) findViewById(R.id.tvReceived);
    TextView tvRecvWarning = (TextView) findViewById(R.id.tvReceivedWarningAmount);
    final WalletAccount selectedAccount = _mbwManager.getSelectedAccount();
    final List<TransactionSummary> transactionsSince = selectedAccount.getTransactionsSince(_receivingSince);
    final ArrayList<TransactionSummary> interesting = new ArrayList<TransactionSummary>();
    CurrencyValue sum = ExactBitcoinValue.ZERO;
    for (TransactionSummary item : transactionsSince) {
        if (item.toAddresses.contains(_address)) {
            interesting.add(item);/*from ww w. jav a2 s  .co m*/
            sum = item.value;
        }
    }

    if (interesting.size() > 0) {
        tvRecv.setText(getString(R.string.incoming_payment)
                + Utils.getFormattedValueWithUnit(sum, _mbwManager.getBitcoinDenomination()));
        // if the user specified an amount, also check it if it matches up...
        if (!CurrencyValue.isNullOrZero(_amount)) {
            tvRecvWarning.setVisibility(sum.equals(_amount) ? View.GONE : View.VISIBLE);
        } else {
            tvRecvWarning.setVisibility(View.GONE);
        }
        tvRecv.setVisibility(View.VISIBLE);
        if (!sum.equals(_lastAddressBalance)) {
            NotificationManager notificationManager = (NotificationManager) this
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext())
                    .setSound(soundUri, AudioManager.STREAM_NOTIFICATION); //This sets the sound to play
            notificationManager.notify(0, mBuilder.build());

            _lastAddressBalance = sum;
        }
    } else {
        tvRecv.setVisibility(View.GONE);
    }
}

From source file:edu.cmu.cylab.starslinger.view.HomeActivity.java

/**
 * Play the in-conversation notification sound (it's the regular
 * notification sound, but played at half-volume
 *///from   w ww.j a v a 2s  . com
private static void playInConversationNotificationSound(Context context) {
    String ringtoneStr = SafeSlingerPrefs.getNotificationRingTone();
    if (TextUtils.isEmpty(ringtoneStr)) {
        // Nothing to play
        return;
    }
    Uri ringtoneUri = Uri.parse(ringtoneStr);
    final NotificationPlayer player = new NotificationPlayer(TAG);
    player.play(context, ringtoneUri, false, AudioManager.STREAM_NOTIFICATION,
            SafeSlingerPrefs.IN_CONVERSATION_NOTIFICATION_VOLUME);

    // Stop the sound after five seconds to handle continuous ringtones
    sHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            player.stop();
        }
    }, 5000);
}

From source file:org.noise_planet.noisecapture.CalibrationLinearityActivity.java

private int getAudioOutput() {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    String value = sharedPref.getString("settings_calibration_audio_output", "STREAM_RING");

    if ("STREAM_VOICE_CALL".equals(value)) {
        return AudioManager.STREAM_VOICE_CALL;
    } else if ("STREAM_SYSTEM".equals(value)) {
        return AudioManager.STREAM_SYSTEM;
    } else if ("STREAM_RING".equals(value)) {
        return AudioManager.STREAM_RING;
    } else if ("STREAM_MUSIC".equals(value)) {
        return AudioManager.STREAM_MUSIC;
    } else if ("STREAM_ALARM".equals(value)) {
        return AudioManager.STREAM_ALARM;
    } else if ("STREAM_NOTIFICATION".equals(value)) {
        return AudioManager.STREAM_NOTIFICATION;
    } else if ("STREAM_DTMF".equals(value)) {
        return AudioManager.STREAM_DTMF;
    } else {//  w  ww . jav  a2 s .  c  o m
        return AudioManager.STREAM_RING;
    }
}

From source file:com.android.mms.transaction.MessagingNotification.java

/**
 * Play the in-conversation notification sound (it's the regular notification sound, but
 * played at half-volume//from w  ww .jav  a  2  s  . com
 */
private static void playInConversationNotificationSound(Context context, long newThreadId) {
    CMConversationSettings conversationSettings = CMConversationSettings.getOrNew(context, newThreadId);
    String ringtoneStr = conversationSettings.getNotificationTone();
    if (TextUtils.isEmpty(ringtoneStr)) {
        // Nothing to play
        return;
    }
    Uri ringtoneUri = Uri.parse(ringtoneStr);
    final NotificationPlayer player = new NotificationPlayer(LogTag.APP);
    player.play(context, ringtoneUri, false, AudioManager.STREAM_NOTIFICATION,
            IN_CONVERSATION_NOTIFICATION_VOLUME);

    // Stop the sound after five seconds to handle continuous ringtones
    sHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            player.stop();
        }
    }, 5000);
}

From source file:com.hhunj.hhudata.ForegroundService.java

private MediaPlayer ring() throws Exception, IOException {

    Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    MediaPlayer player = new MediaPlayer();

    player.setDataSource(this, alert);

    final AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    if (audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION) != 0) {

        player.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);

        player.setLooping(true);//w ww. j av  a  2s. com

        player.prepare();

        player.start();

    }

    return player;

}

From source file:com.yahala.android.NotificationsController.java

private void showOrUpdateNotification(boolean notifyAboutLast) {
    if (!UserConfig.isClientActivated() || pushMessages.isEmpty()) {
        dismissNotification();/*w w w.  j a v  a  2s.  co  m*/
        return;
    }
    try {
        XMPPManager.getInstance().maybeStartReconnect();

        MessageObject lastMessageObject = pushMessages.get(0);

        String dialog_id = lastMessageObject.getDialogId();
        // String chat_id = lastMessageObject.messageOwner.to_id.chat_id;
        String user_jid = lastMessageObject.messageOwner.getJid();
        /*if (user_jid == 0) {
        user_jid = lastMessageObject.messageOwner.from_id;
        } else if (usjer_id == UserConfig.getClientUserId()) {
        user_jid = lastMessageObject.messageOwner.from_id;
        }*/

        TLRPC.User user = ContactsController.getInstance().friendsDict.get(user_jid);
        TLRPC.Chat chat = null;
        /*if (chat_id != 0) {
        chat = MessagesController.getInstance().chats.get(chat_id);
        }*/
        TLRPC.FileLocation photoPath = null;

        boolean notifyDisabled = false;
        boolean needVibrate = false;
        String choosenSoundPath = null;
        int ledColor = 0xff00ff00;
        boolean inAppSounds = false;
        boolean inAppVibrate = false;
        boolean inAppPreview = false;
        int vibrate_override = 0;

        SharedPreferences preferences = ApplicationLoader.applicationContext
                .getSharedPreferences("Notifications", Context.MODE_PRIVATE);
        int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
        /*  if (!notifyAboutLast || notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || chat_id != 0 && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0) {
        notifyDisabled = true;
          }*/

        String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
        if (!notifyDisabled) {
            inAppSounds = preferences.getBoolean("EnableInAppSounds", true);
            inAppVibrate = preferences.getBoolean("EnableInAppVibrate", true);
            inAppPreview = preferences.getBoolean("EnableInAppPreview", true);
            vibrate_override = preferences.getInt("vibrate_" + dialog_id, 0);

            choosenSoundPath = preferences.getString("sound_path_" + dialog_id, null);
            /* if (chat_id != 0) {
            if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) {
                choosenSoundPath = null;
            } else if (choosenSoundPath == null) {
                choosenSoundPath = preferences.getString("GroupSoundPath", defaultPath);
            }
            needVibrate = preferences.getBoolean("EnableVibrateGroup", true);
            ledColor = preferences.getInt("GroupLed", 0xff00ff00);
             } else*/
            if (user_jid.equals("0")) {
                if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) {
                    choosenSoundPath = null;
                } else if (choosenSoundPath == null) {
                    choosenSoundPath = preferences.getString("GlobalSoundPath", defaultPath);
                }
                needVibrate = preferences.getBoolean("EnableVibrateAll", true);
                ledColor = preferences.getInt("MessagesLed", 0xff00ff00);
            }
            if (preferences.contains("color_" + dialog_id)) {
                ledColor = preferences.getInt("color_" + dialog_id, 0);
            }

            if (!needVibrate && vibrate_override == 1) {
                needVibrate = true;
            } else if (needVibrate && vibrate_override == 2) {
                needVibrate = false;
            }
            if (!ApplicationLoader.mainInterfacePaused) {
                if (!inAppSounds) {
                    choosenSoundPath = null;
                }
                if (!inAppVibrate) {
                    needVibrate = false;
                }
            }
        }

        Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
        intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
        intent.setFlags(32768);
        if (dialog_id != "0") {
            // if (chat_id != 0) {
            //     intent.putExtra("chatId", chat_id);
            // } else if (user_id != 0) {
            intent.putExtra("user_jid", user_jid);
            //  }
            if (pushDialogs.size() == 1) {
                if (chat != null) {
                    if (chat.photo != null && chat.photo.photo_small != null
                            && chat.photo.photo_small.volume_id != 0 && chat.photo.photo_small.local_id != 0) {
                        photoPath = chat.photo.photo_small;
                    }
                } else {
                    if (user.photo != null && user.photo.photo_small != null
                            && user.photo.photo_small.volume_id != 0 && user.photo.photo_small.local_id != 0) {
                        photoPath = user.photo.photo_small;
                    }
                }
            }
        }
        PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent,
                PendingIntent.FLAG_ONE_SHOT);

        String name = null;
        boolean replace = true;
        if (dialog_id == "0" || pushDialogs.size() > 1) {
            name = LocaleController.getString("AppName", R.string.AppName);
            replace = false;
        } else {
            if (chat != null) {
                name = chat.title;
            } else {
                name = Utilities.formatName(user.first_name, user.last_name);
            }
        }

        String detailText = null;
        if (pushDialogs.size() == 1) {
            detailText = LocaleController.formatPluralString("NewMessages", total_unread_count);
        } else {
            detailText = String.format("%s %s",
                    LocaleController.formatPluralString("NewMessages", total_unread_count),
                    LocaleController.formatPluralString("FromContacts", pushDialogs.size()));
        }

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                ApplicationLoader.applicationContext).setContentTitle(name)
                        .setSmallIcon(R.drawable.notification).setAutoCancel(true).setContentText(detailText)
                        .setContentIntent(contentIntent);

        String lastMessage = null;
        if (pushMessages.size() == 1) {
            String message = lastMessage = getStringForMessage(pushMessages.get(0));
            if (message == null) {
                return;
            }
            if (replace) {
                if (chat != null) {
                    message = message.replace(" @ " + name, "");
                } else {
                    message = message.replace(name + ": ", "").replace(name + " ", "");
                }
            }
            mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
        } else {
            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
            inboxStyle.setBigContentTitle(name);
            int count = Math.min(10, pushMessages.size());
            for (int i = 0; i < count; i++) {
                String message = getStringForMessage(pushMessages.get(i));
                if (message == null) {
                    continue;
                }
                if (i == 0) {
                    lastMessage = message;
                }
                if (pushDialogs.size() == 1) {
                    if (replace) {
                        if (chat != null) {
                            message = message.replace(" @ " + name, "");
                        } else {
                            message = message.replace(name + ": ", "").replace(name + " ", "");
                        }
                    }
                }
                inboxStyle.addLine(message);
            }
            inboxStyle.setSummaryText(detailText);
            mBuilder.setStyle(inboxStyle);
        }

        if (photoPath != null) {
            Bitmap img = FileLoader.getInstance().getImageFromMemory(photoPath, null, null, "50_50", false);
            if (img != null) {
                mBuilder.setLargeIcon(img);
            }
        }

        if (!notifyDisabled) {
            if (ApplicationLoader.mainInterfacePaused || inAppPreview) {
                mBuilder.setTicker(lastMessage);
            }
            if (choosenSoundPath != null && !choosenSoundPath.equals("NoSound")) {
                if (choosenSoundPath.equals(defaultPath)) {
                    mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI,
                            AudioManager.STREAM_NOTIFICATION);
                } else {
                    mBuilder.setSound(Uri.parse(choosenSoundPath), AudioManager.STREAM_NOTIFICATION);
                }
            }
            if (ledColor != 0) {
                mBuilder.setLights(ledColor, 1000, 1000);
            }
            if (needVibrate) {
                mBuilder.setVibrate(new long[] { 0, 100, 0, 100 });
            }
        } else {
            mBuilder.setVibrate(new long[] { 0, 0 });
        }

        notificationManager.notify(1, mBuilder.build());
        if (preferences.getBoolean("EnablePebbleNotifications", false)) {
            sendAlertToPebble(lastMessage);
        }
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}