Example usage for android.app Notification STREAM_DEFAULT

List of usage examples for android.app Notification STREAM_DEFAULT

Introduction

In this page you can find the example usage for android.app Notification STREAM_DEFAULT.

Prototype

int STREAM_DEFAULT

To view the source code for android.app Notification STREAM_DEFAULT.

Click Source Link

Document

Use this constant as the value for audioStreamType to request that the default stream type for notifications be used.

Usage

From source file:ti.modules.titanium.android.notificationmanager.NotificationProxy.java

public NotificationProxy() {
    super();/*  w w w .  j a v a 2  s.c  o m*/
    notificationBuilder = new NotificationCompat.Builder(TiApplication.getInstance().getApplicationContext())
            .setSmallIcon(android.R.drawable.stat_sys_warning).setWhen(System.currentTimeMillis());

    //set up default values
    flags = Notification.FLAG_AUTO_CANCEL;
    audioStreamType = Notification.STREAM_DEFAULT;
}

From source file:org.nerdcircus.android.klaxon.Notifier.java

/** return our notification object.
 *//*from w w w. ja  v a 2  s .co  m*/
Notification getNotification(Context context, String subject) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    Uri alertsound = Uri.parse(prefs.getString("alert_sound", "DEFAULT"));
    if (alertsound.toString().equals("DEFAULT")) {
        //no setting. use default.
        alertsound = Settings.System.DEFAULT_NOTIFICATION_URI;
    }

    Intent listIntent = new Intent(Intent.ACTION_VIEW);
    listIntent.setType("vnd.android.cursor.dir/pages");
    Intent cancelIntent = new Intent(Pager.SILENCE_ACTION);

    NotificationCompat.Builder nb = new NotificationCompat.Builder(context);
    nb.setSmallIcon(R.drawable.bar_icon);
    nb.setPriority(NotificationCompat.PRIORITY_MAX);
    nb.setLights(R.color.red, 1000, 100);

    int streamtype = Notification.STREAM_DEFAULT;
    if (prefs.getBoolean("use_alarm_stream", false)) {
        streamtype = AudioManager.STREAM_ALARM;
    }
    nb.setSound(alertsound, streamtype);
    nb.setContentTitle(subject);
    nb.setContentIntent(PendingIntent.getActivity(context, 0, listIntent, 0));
    nb.setDeleteIntent(PendingIntent.getBroadcast(context, 0, cancelIntent, 0));
    nb.setAutoCancel(true);

    //vibrate!
    if (prefs.getBoolean("vibrate", true)) {
        nb.setVibrate(new long[] { 0, 800, 500, 800 });
    }

    return nb.build();
}

From source file:org.mariotaku.twidere.provider.TweetStoreProvider.java

private Notification buildNotification(final NotificationCompat.Builder builder, final String ticker,
        final String title, final String message, final int icon, final Bitmap large_icon,
        final Intent content_intent, final Intent delete_intent) {
    final Context context = getContext();
    builder.setTicker(ticker);/*from  w  w w.  ja v  a  2s .c om*/
    builder.setContentTitle(title);
    builder.setContentText(message);
    builder.setAutoCancel(true);
    builder.setWhen(System.currentTimeMillis());
    builder.setSmallIcon(icon);
    if (large_icon != null) {
        builder.setLargeIcon(large_icon);
    }
    if (delete_intent != null) {
        builder.setDeleteIntent(
                PendingIntent.getBroadcast(context, 0, delete_intent, PendingIntent.FLAG_UPDATE_CURRENT));
    }
    if (content_intent != null) {
        builder.setContentIntent(
                PendingIntent.getActivity(context, 0, content_intent, PendingIntent.FLAG_UPDATE_CURRENT));
    }
    int defaults = 0;
    final Calendar now = Calendar.getInstance();
    if (mNotificationIsAudible
            && !mPreferences.getBoolean("slient_notifications_at_" + now.get(Calendar.HOUR_OF_DAY), false)) {
        if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_SOUND, false)) {
            builder.setSound(Uri.parse(mPreferences.getString(PREFERENCE_KEY_NOTIFICATION_RINGTONE,
                    Settings.System.DEFAULT_RINGTONE_URI.getPath())), Notification.STREAM_DEFAULT);
        }
        if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_VIBRATION, false)) {
            defaults |= Notification.DEFAULT_VIBRATE;
        }
    }
    if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_LIGHTS, false)) {
        final int color_def = context.getResources().getColor(R.color.holo_blue_dark);
        final int color = mPreferences.getInt(PREFERENCE_KEY_NOTIFICATION_LIGHT_COLOR, color_def);
        builder.setLights(color, 1000, 2000);
    }
    builder.setDefaults(defaults);
    return builder.build();
}

From source file:org.mariotaku.twidere.provider.TwidereDataProvider.java

private void buildNotification(final NotificationCompat.Builder builder, final String ticker,
        final String title, final String message, final int icon, final Bitmap large_icon,
        final Intent content_intent, final Intent delete_intent) {
    final Context context = getContext();
    builder.setTicker(ticker);//  w ww .java  2s.  co m
    builder.setContentTitle(title);
    builder.setContentText(message);
    builder.setAutoCancel(true);
    builder.setWhen(System.currentTimeMillis());
    builder.setSmallIcon(icon);
    if (large_icon != null) {
        builder.setLargeIcon(large_icon);
    }
    if (delete_intent != null) {
        builder.setDeleteIntent(
                PendingIntent.getBroadcast(context, 0, delete_intent, PendingIntent.FLAG_UPDATE_CURRENT));
    }
    if (content_intent != null) {
        builder.setContentIntent(
                PendingIntent.getActivity(context, 0, content_intent, PendingIntent.FLAG_UPDATE_CURRENT));
    }
    int defaults = 0;
    final Calendar now = Calendar.getInstance();
    if (mNotificationIsAudible
            && !mPreferences.getBoolean("slient_notifications_at_" + now.get(Calendar.HOUR_OF_DAY), false)) {
        if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_SOUND, false)) {
            builder.setSound(Uri.parse(mPreferences.getString(PREFERENCE_KEY_NOTIFICATION_RINGTONE,
                    Settings.System.DEFAULT_RINGTONE_URI.getPath())), Notification.STREAM_DEFAULT);
        }
        if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_VIBRATION, false)) {
            defaults |= Notification.DEFAULT_VIBRATE;
        }
    }
    if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_LIGHTS, false)) {
        final int color_def = context.getResources().getColor(R.color.holo_blue_dark);
        final int color = mPreferences.getInt(PREFERENCE_KEY_NOTIFICATION_LIGHT_COLOR, color_def);
        builder.setLights(color, 1000, 2000);
    }
    builder.setDefaults(defaults);
}

From source file:org.mariotaku.twidere.util.AsyncTwitterWrapper.java

private Notification buildNotification(final String title, final String message, final int icon,
        final Intent content_intent, final Intent delete_intent) {
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);
    builder.setTicker(message);/*from  w  w w .  ja va  2  s  . c o  m*/
    builder.setContentTitle(title);
    builder.setContentText(message);
    builder.setAutoCancel(true);
    builder.setWhen(System.currentTimeMillis());
    builder.setSmallIcon(icon);
    if (delete_intent != null) {
        builder.setDeleteIntent(
                PendingIntent.getBroadcast(mContext, 0, delete_intent, PendingIntent.FLAG_UPDATE_CURRENT));
    }
    if (content_intent != null) {
        builder.setContentIntent(
                PendingIntent.getActivity(mContext, 0, content_intent, PendingIntent.FLAG_UPDATE_CURRENT));
    }
    int defaults = 0;
    if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_SOUND, false)) {
        builder.setSound(Uri.parse(mPreferences.getString(PREFERENCE_KEY_NOTIFICATION_RINGTONE,
                Settings.System.DEFAULT_RINGTONE_URI.getPath())), Notification.STREAM_DEFAULT);
    }
    if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_VIBRATION, false)) {
        defaults |= Notification.DEFAULT_VIBRATE;
    }
    if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_LIGHTS, false)) {
        final int color_def = mResources.getColor(R.color.holo_blue_dark);
        final int color = mPreferences.getInt(PREFERENCE_KEY_NOTIFICATION_LIGHT_COLOR, color_def);
        builder.setLights(color, 1000, 2000);
    }
    builder.setDefaults(defaults);
    return builder.build();
}

From source file:org.mariotaku.twidere.service.TwidereService.java

private Notification buildNotification(String message, int icon, Intent content_intent, Intent delete_intent) {
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setTicker(message);//from  ww  w . j a  v  a2  s .  c o m
    builder.setContentTitle(getString(R.string.new_notifications));
    builder.setContentText(message);
    builder.setAutoCancel(true);
    builder.setWhen(System.currentTimeMillis());
    builder.setSmallIcon(icon);
    builder.setDeleteIntent(
            PendingIntent.getBroadcast(this, 0, delete_intent, PendingIntent.FLAG_UPDATE_CURRENT));
    builder.setContentIntent(
            PendingIntent.getActivity(this, 0, content_intent, PendingIntent.FLAG_UPDATE_CURRENT));
    int defaults = 0;
    if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_SOUND, false)) {
        builder.setSound(Uri.parse(mPreferences.getString(PREFERENCE_KEY_NOTIFICATION_RINGTONE,
                Settings.System.DEFAULT_RINGTONE_URI.getPath())), Notification.STREAM_DEFAULT);
    }
    if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_VIBRATION, false)) {
        defaults |= Notification.DEFAULT_VIBRATE;
    }
    if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_LIGHTS, false)) {
        final int color_def = getResources().getColor(R.color.holo_blue_light);
        final int color = mPreferences.getInt(PREFERENCE_KEY_NOTIFICATION_LIGHT_COLOR, color_def);
        builder.setLights(color, 1000, 2000);
    }
    builder.setDefaults(defaults);
    return builder.getNotification();
}

From source file:com.dwdesign.tweetings.service.TweetingsService.java

private Notification buildNotification(final String title, final String message, final int icon,
        final Intent content_intent, final Intent delete_intent) {
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setTicker(message);//from  w  w  w  . j av  a  2 s  . c om
    builder.setContentTitle(title);
    builder.setContentText(message);
    builder.setAutoCancel(true);
    builder.setWhen(System.currentTimeMillis());
    builder.setSmallIcon(icon);
    if (delete_intent != null) {
        builder.setDeleteIntent(
                PendingIntent.getBroadcast(this, 0, delete_intent, PendingIntent.FLAG_UPDATE_CURRENT));
    }
    if (content_intent != null) {
        builder.setContentIntent(
                PendingIntent.getActivity(this, 0, content_intent, PendingIntent.FLAG_UPDATE_CURRENT));
    }
    int defaults = 0;
    final Calendar now = Calendar.getInstance();
    if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_SOUND, true)
            && !mPreferences.getBoolean("silent_notifications_at_" + now.get(Calendar.HOUR_OF_DAY), false)) {
        Uri soundUri = Uri.parse(mPreferences.getString(PREFERENCE_KEY_NOTIFICATION_RINGTONE,
                "android.resource://" + getPackageName() + "/" + R.raw.notify));
        builder.setSound(soundUri, Notification.STREAM_DEFAULT);
    }
    if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_VIBRATION, true)
            && !mPreferences.getBoolean("silent_notifications_at_" + now.get(Calendar.HOUR_OF_DAY), false)) {
        defaults |= Notification.DEFAULT_VIBRATE;
    }
    if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATION_HAVE_LIGHTS, true)
            && !mPreferences.getBoolean("silent_notifications_at_" + now.get(Calendar.HOUR_OF_DAY), false)) {
        final int color_def = getResources().getColor(R.color.holo_blue_dark);
        final int color = mPreferences.getInt(PREFERENCE_KEY_NOTIFICATION_LIGHT_COLOR, color_def);
        builder.setLights(color, 1000, 2000);
    }
    builder.setDefaults(defaults);
    return builder.getNotification();
}