Example usage for android.app Notification DEFAULT_VIBRATE

List of usage examples for android.app Notification DEFAULT_VIBRATE

Introduction

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

Prototype

int DEFAULT_VIBRATE

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

Click Source Link

Document

Use the default notification vibrate.

Usage

From source file:com.example.mego.adas.utils.NotificationUtils.java

/**
 * Helper Method to create and display the notification for advices
 *
 * @param context//from w ww . ja  v  a2  s . c  o  m
 */
public static void remindUserWithCarAdvices(Context context) {

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
            .setColor(ContextCompat.getColor(context, R.color.colorPrimary)).setSmallIcon(R.mipmap.ic_launcher)
            .setLargeIcon(largeIcon(context))
            .setContentTitle(context.getString(R.string.notification_remind_user_advices_title))
            .setContentText(showRandomCarAdvices(context))
            .setStyle(new NotificationCompat.BigTextStyle().bigText(showRandomCarAdvices(context)))
            .setDefaults(Notification.DEFAULT_VIBRATE).setDefaults(Notification.DEFAULT_SOUND)
            .setContentIntent(contentIntent(context)).setAutoCancel(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        notificationBuilder.setPriority(Notification.PRIORITY_HIGH);
    }

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(ADAS_ADVICES_NOTIFICATION_ID, notificationBuilder.build());
}

From source file:com.example.android.background.utilities.NotificationUtils.java

public static void remindUserBecauseCharging(Context context) {

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
            .setColor(ContextCompat.getColor(context, R.color.colorPrimary))
            .setSmallIcon(R.drawable.ic_drink_notification).setLargeIcon(largeIcon(context))
            .setContentTitle(context.getString(R.string.charging_reminder_notification_title))
            .setContentText(context.getString(R.string.charging_reminder_notification_body))
            .setStyle(new NotificationCompat.BigTextStyle()
                    .bigText(context.getString(R.string.charging_reminder_notification_body)))
            .setDefaults(Notification.DEFAULT_VIBRATE).setContentIntent(contentIntent(context))
            .addAction(drinkWaterAction(context)).addAction(ignoreReminderAction(context)).setAutoCancel(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        notificationBuilder.setPriority(Notification.PRIORITY_HIGH);
    }// w w w .j a va 2  s  .  co  m

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    /* WATER_REMINDER_NOTIFICATION_ID allows you to update or cancel the notification later on */
    notificationManager.notify(WATER_REMINDER_NOTIFICATION_ID, notificationBuilder.build());
}

From source file:com.jsw.callcastreceiver.Call_BroadCastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();//from  www.  j  a v  a 2s  . c om
    if (bundle != null) {
        String state = bundle.getString(TelephonyManager.EXTRA_STATE);
        if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
            String number = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);

            Intent newIntent = new Intent(context, Telefon_Activity.class);
            newIntent.putExtra("number", number);
            PendingIntent pending = PendingIntent.getActivity(context, CALLNOTIFICATION, newIntent,
                    PendingIntent.FLAG_ONE_SHOT);
            NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
            builder.setContentTitle("Telefon Activity");
            builder.setSmallIcon(R.mipmap.ic_launcher);
            builder.setContentText("Incoming call from: " + number);
            builder.setDefaults(Notification.DEFAULT_VIBRATE);
            builder.setDefaults(Notification.DEFAULT_LIGHTS);
            //Aadir el objeto PendingItem a la notificicacion
            builder.setContentIntent(pending);
            //Aadir la notificacion al Manager
            NotificationManager notify = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            notify.notify(CALLNOTIFICATION, builder.build());
        }
    }
}

From source file:com.banana.instagrab.helper.NotificationUtils.java

public static void remindUserBecauseCharging(Context context) {
    // COMPLETED (8) In the remindUser method use NotificationCompat.Builder to create a notification
    // that:/*from w  w  w. j  a  va  2s .c  om*/
    // - has a color of R.colorPrimary - use ContextCompat.getColor to get a compatible color
    // - has ic_drink_notification as the small icon
    // - uses icon returned by the largeIcon helper method as the large icon
    // - sets the title to the charging_reminder_notification_title String resource
    // - sets the text to the charging_reminder_notification_body String resource
    // - sets the style to NotificationCompat.BigTextStyle().bigText(text)
    // - sets the notification defaults to vibrate
    // - uses the content intent returned by the contentIntent helper method for the contentIntent
    // - automatically cancels the notification when the notification is clicked
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
            //.setColor(ContextCompat.getColor(context, R.color.colorPrimary))
            //.setSmallIcon(R.drawable.ic_drink_notification)
            //.setLargeIcon(largeIcon(context))
            .setContentTitle("?!").setContentText("?!")
            //.setStyle(new NotificationCompat.MessagingStyle.Message()
            .setDefaults(Notification.DEFAULT_VIBRATE).setContentIntent(contentIntent(context))
            .setAutoCancel(false);

    Log.d("hahaha", "1");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        notificationBuilder.setPriority(Notification.PRIORITY_HIGH);
    }
    Log.d("hahaha", "2");
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Log.d("hahaha", "3");
    notificationManager.notify(WATER_REMINDER_NOTIFICATION_ID, notificationBuilder.build());
    Log.d("hahaha", "4");
}

From source file:com.innoc.secureline.ui.NotificationBarManager.java

public static void notifyMissedCall(Context context, String remoteNumber) {
    Intent intent = new Intent(DialerActivity.CALL_LOG_ACTION, null, context, DialerActivity.class);
    PendingIntent launchIntent = PendingIntent.getActivity(context, 0, intent, 0);
    PersonInfo remoteInfo = PersonInfo.getInstance(context, remoteNumber);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setSmallIcon(R.drawable.stat_notify_missed_call);
    builder.setWhen(System.currentTimeMillis());
    builder.setTicker(context.getString(R.string.NotificationBarManager_missed_redphone_call_from_s,
            remoteInfo.getName()));/*w  w  w . j a  va 2 s . c o m*/
    builder.setContentTitle(context.getString(R.string.NotificationBarManager_missed_redphone_call));
    builder.setContentText(remoteInfo.getName());
    builder.setContentIntent(launchIntent);
    builder.setDefaults(Notification.DEFAULT_VIBRATE);
    builder.setAutoCancel(true);

    NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    manager.notify(DialerActivity.MISSED_CALL, builder.build());
}

From source file:com.saarang.samples.apps.iosched.ui.debug.actions.ShowSessionNotificationDebugAction.java

@Override
public void run(Context context, Callback callback) {

    Intent i = new Intent(Intent.ACTION_VIEW, ScheduleContract.Sessions.buildSessionUri("__keynote__"));

    PendingIntent pi = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
    Intent mapIntent = new Intent(context, UIUtils.getMapActivityClass(context));
    mapIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
    mapIntent.putExtra(BaseMapActivity.EXTRA_ROOM, "keynote");
    PendingIntent piMap = TaskStackBuilder.create(context).addNextIntent(mapIntent).getPendingIntent(0,
            PendingIntent.FLAG_CANCEL_CURRENT);

    //= PendingIntent.getActivity(context, 0, mapIntent, 0);

    NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context)
            .setContentTitle("test notification").setContentText("yep, this is a test")
            .setTicker("hey, you got a test")
            .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
            .setSmallIcon(com.saarang.samples.apps.iosched.R.drawable.ic_stat_notification).setContentIntent(pi)
            .setPriority(Notification.PRIORITY_MAX).setAutoCancel(true);
    notifBuilder.addAction(com.saarang.samples.apps.iosched.R.drawable.ic_map_holo_dark,
            context.getString(com.saarang.samples.apps.iosched.R.string.title_map), piMap);

    NotificationCompat.InboxStyle richNotification = new NotificationCompat.InboxStyle(notifBuilder)
            .setBigContentTitle(context.getResources().getQuantityString(
                    com.saarang.samples.apps.iosched.R.plurals.session_notification_title, 1, 8, 1));

    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(32534, richNotification.build());

}

From source file:com.google.samples.apps.iosched.debug.actions.ShowSessionNotificationDebugAction.java

@Override
public void run(Context context, Callback callback) {

    Intent i = new Intent(Intent.ACTION_VIEW, ScheduleContract.Sessions.buildSessionUri("__keynote__"));

    PendingIntent pi = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
    Intent mapIntent = new Intent(context, MapActivity.class);
    mapIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
    mapIntent.putExtra(MapActivity.EXTRA_ROOM, "keynote");
    PendingIntent piMap = TaskStackBuilder.create(context).addNextIntent(mapIntent).getPendingIntent(0,
            PendingIntent.FLAG_CANCEL_CURRENT);

    //= PendingIntent.getActivity(context, 0, mapIntent, 0);

    NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context)
            .setContentTitle("test notification").setContentText("yep, this is a test")
            .setTicker("hey, you got a test")
            .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
            .setSmallIcon(R.drawable.ic_stat_notification).setContentIntent(pi)
            .setPriority(Notification.PRIORITY_MAX).setAutoCancel(true);
    notifBuilder.addAction(R.drawable.ic_map_holo_dark, context.getString(R.string.title_map), piMap);

    NotificationCompat.InboxStyle richNotification = new NotificationCompat.InboxStyle(notifBuilder)
            .setBigContentTitle(//from  w w  w  .j  a v  a2 s.  c o  m
                    context.getResources().getQuantityString(R.plurals.session_notification_title, 1, 8, 1));

    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(32534, richNotification.build());

}

From source file:com.grarak.cafntracker.MessagingServer.java

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);

    String name = remoteMessage.getData().get("name");
    String title = remoteMessage.getData().get("title");
    String message = remoteMessage.getData().get("message");
    String link = remoteMessage.getData().get("link");

    if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean(name, false)) {
        return;/*from  w ww .  jav  a2 s.c o  m*/
    }

    String filter = PreferenceManager.getDefaultSharedPreferences(this).getString(name + "_filter", "");
    String filtertag = PreferenceManager.getDefaultSharedPreferences(this).getString(name + "_filtertag", "");
    if ((!filter.isEmpty() && !title.contains(filter))
            || (!filtertag.isEmpty() && !message.contains(filtertag))) {
        return;
    }

    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(link));

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i, 0);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle(title.isEmpty() ? name : name + ": " + title).setContentText(message)
            .setContentIntent(pendingIntent)
            .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);

    int id = PreferenceManager.getDefaultSharedPreferences(this).getInt("notification", 0);

    NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mNotifyMgr.notify(id, builder.build());
    PreferenceManager.getDefaultSharedPreferences(this).edit().putInt("notification", id + 1).apply();

}

From source file:weekendhacks.com.kahahaibosedk.MyFirebaseMessagingService.java

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

    // TODO(developer): Handle FCM messages here.
    // Not getting messages here? See why this may be: https://goo.gl/39bRNJ
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

    Log.d(TAG, "From: " + remoteMessage.getFrom());

    // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
        Log.d(TAG, "Message data payload: " + remoteMessage.getData());
    }//w  ww  . ja v a2  s. co m

    // Check if message contains a notification payload.
    if (remoteMessage.getNotification() != null) {
        Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
    }

    mBuilder.setSmallIcon(R.drawable.notification_icon).setContentTitle("From :" + remoteMessage.getFrom());
    if (remoteMessage.getNotification() != null) {
        Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
        mBuilder.setContentText(remoteMessage.getNotification().getBody());
    }

    mBuilder.setDefaults(
            Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
    int mNotificationId = 001;
    NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    // Builds the notification and issues it.
    mNotifyMgr.notify(mNotificationId, mBuilder.build());
}

From source file:org.linphone.compatibility.ApiElevenPlus.java

public static Notification createSimpleNotification(Context context, String title, String text,
        PendingIntent intent) {/* w w w .  j a v a2 s  .co m*/
    NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title).setContentText(text)
            .setContentIntent(intent);

    Notification notif = notifBuilder.build();
    notif.defaults |= Notification.DEFAULT_VIBRATE;
    notif.defaults |= Notification.DEFAULT_SOUND;
    notif.defaults |= Notification.DEFAULT_LIGHTS;

    return notif;
}