List of usage examples for android.app Notification DEFAULT_VIBRATE
int DEFAULT_VIBRATE
To view the source code for android.app Notification DEFAULT_VIBRATE.
Click Source Link
From source file:com.craftsilicon.littlecabrider.GCMIntentService.java
private void generateNotificationNew(Context context, String message) { final Notification.Builder builder = new Notification.Builder(this); builder.setDefaults(// w w w . j av a 2 s. co m Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE); builder.setStyle(new Notification.BigTextStyle(builder).bigText(message) .setBigContentTitle(context.getString(R.string.app_name))) .setContentTitle(context.getString(R.string.app_name)).setContentText(message) .setSmallIcon(R.drawable.ic_launcher); builder.setAutoCancel(true); Intent notificationIntent = new Intent(context, MainDrawerActivity.class); notificationIntent.putExtra("fromNotification", "notification"); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(intent); final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(0, builder.build()); }
From source file:com.gsma.rcs.ri.sharing.image.ImageSharingIntentService.java
/** * Add image share notification/*from w ww . ja v a 2 s . com*/ * * @param invitation Intent invitation * @param ishDao the image sharing data object */ private void addImageSharingInvitationNotification(Intent invitation, ImageSharingDAO ishDao) { ContactId contact = ishDao.getContact(); if (contact == null) { if (LogUtils.isActive) { Log.e(LOGTAG, "addImageSharingInvitationNotification failed: cannot parse contact"); } return; } /* Create pending intent */ Intent intent = new Intent(invitation); intent.setClass(this, ReceiveImageSharing.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); /* * If the PendingIntent has the same operation, action, data, categories, components, and * flags it will be replaced. Invitation should be notified individually so we use a random * generator to provide a unique request code and reuse it for the notification. */ int uniqueId = Utils.getUniqueIdForPendingIntent(); PendingIntent contentIntent = PendingIntent.getActivity(this, uniqueId, intent, PendingIntent.FLAG_ONE_SHOT); String displayName = RcsContactUtil.getInstance(this).getDisplayName(contact); String title = getString(R.string.title_recv_image_sharing); /* Create notification */ NotificationCompat.Builder notif = new NotificationCompat.Builder(this); notif.setContentIntent(contentIntent); notif.setSmallIcon(R.drawable.ri_notif_csh_icon); notif.setWhen(System.currentTimeMillis()); notif.setAutoCancel(true); notif.setOnlyAlertOnce(true); notif.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); notif.setDefaults(Notification.DEFAULT_VIBRATE); notif.setContentTitle(title); notif.setContentText(getString(R.string.label_from_args, displayName)); /* Send notification */ NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(uniqueId, notif.build()); }
From source file:com.cyeam.cInterphone.ui.CInterphone.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // Set default fragment. mViewPager.setCurrentItem(1);/* w ww .j av a 2s. c o m*/ // Account[] accounts = AccountManager.get(this).getAccountsByType( // "com.google"); // if (accounts.length > 0) { // Settings.DEFAULT_USERNAME = accounts[0].name; // } Receiver.engine(this).StartEngine(); PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, Utils.getMetaValue(CInterphone.this, "api_key")); CustomPushNotificationBuilder cBuilder = new CustomPushNotificationBuilder(this, R.layout.ongoing_call_notification, R.id.icon, R.id.text1, R.id.text2); cBuilder.setNotificationFlags(Notification.FLAG_AUTO_CANCEL); cBuilder.setNotificationDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); cBuilder.setStatusbarIcon(R.drawable.icon64); cBuilder.setLayoutDrawable(R.drawable.icon22); PushManager.setNotificationBuilder(this, 0, cBuilder); Push.Push(new com.cyeam.cInterphone.model.Notification("hello, world")); }
From source file:com.gsma.rcs.ri.sharing.video.VideoSharingIntentService.java
/** * Add video share notification/*from ww w. ja v a2 s . co m*/ * * @param invitation Intent invitation * @param vshDao the video sharing data object */ public void addVideoSharingInvitationNotification(Intent invitation, VideoSharingDAO vshDao) { if (vshDao.getContact() == null) { if (LogUtils.isActive) { Log.e(LOGTAG, "VideoSharingInvitationReceiver failed: cannot parse contact"); } return; } /* Create pending intent */ Intent intent = new Intent(invitation); intent.setClass(this, IncomingVideoSharing.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); /* * If the PendingIntent has the same operation, action, data, categories, components, and * flags it will be replaced. Invitation should be notified individually so we use a random * generator to provide a unique request code and reuse it for the notification. */ int uniqueId = Utils.getUniqueIdForPendingIntent(); PendingIntent contentIntent = PendingIntent.getActivity(this, uniqueId, intent, PendingIntent.FLAG_ONE_SHOT); String displayName = RcsContactUtil.getInstance(this).getDisplayName(vshDao.getContact()); String notifTitle = getString(R.string.title_recv_video_sharing); /* Create notification */ NotificationCompat.Builder notif = new NotificationCompat.Builder(this); notif.setContentIntent(contentIntent); notif.setSmallIcon(R.drawable.ri_notif_csh_icon); notif.setWhen(System.currentTimeMillis()); notif.setAutoCancel(true); notif.setOnlyAlertOnce(true); notif.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); notif.setDefaults(Notification.DEFAULT_VIBRATE); notif.setContentTitle(notifTitle); notif.setContentText(getString(R.string.label_from_args, displayName)); /* Send notification */ NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(uniqueId, notif.build()); }
From source file:com.money.manager.ex.notifications.RecurringTransactionNotifications.java
private void showNotification(Cursor cursor) { CurrencyService currencyService = new CurrencyService(mContext); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); while (cursor.moveToNext()) { String payeeName = cursor.getString(cursor.getColumnIndex(QueryBillDeposits.PAYEENAME)); // check if payee name is null, then put toAccountName if (TextUtils.isEmpty(payeeName)) payeeName = cursor.getString(cursor.getColumnIndex(QueryBillDeposits.TOACCOUNTNAME)); // compose text String line = cursor.getString(cursor.getColumnIndex(QueryBillDeposits.USERNEXTOCCURRENCEDATE)) + " " + payeeName + ": <b>" + currencyService.getCurrencyFormatted( cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.CURRENCYID)), MoneyFactory/*w w w.jav a 2 s .c o m*/ .fromDouble(cursor.getDouble(cursor.getColumnIndex(QueryBillDeposits.AMOUNT)))) + "</b>"; // add line inboxStyle.addLine(Html.fromHtml("<small>" + line + "</small>")); } NotificationManager notificationManager = (NotificationManager) getContext() .getSystemService(Context.NOTIFICATION_SERVICE); // create pending intent Intent intent = new Intent(getContext(), RecurringTransactionListActivity.class); // set launch from notification // check pin code intent.putExtra(RecurringTransactionListActivity.INTENT_EXTRA_LAUNCH_NOTIFICATION, true); PendingIntent pendingIntent = PendingIntent.getActivity(getContext(), 0, intent, 0); // todo: Actions // Intent skipIntent = new Intent(intent); // //skipIntent.setAction(Intent.) // PendingIntent skipPending = PendingIntent.getActivity(getContext(), 0, skipIntent, 0); // Intent enterIntent = new Intent(getContext(), RecurringTransactionEditActivity.class); // PendingIntent enterPending = PendingIntent.getActivity(getContext(), 0, enterIntent, 0); // create notification try { Notification notification = new NotificationCompat.Builder(getContext()).setAutoCancel(true) .setContentIntent(pendingIntent).setContentTitle(mContext.getString(R.string.application_name)) .setContentText(mContext.getString(R.string.notification_repeating_transaction_expired)) .setSubText(mContext.getString(R.string.notification_click_to_check_repeating_transaction)) .setSmallIcon(R.drawable.ic_stat_notification) .setTicker(mContext.getString(R.string.notification_repeating_transaction_expired)) .setDefaults( Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS) .setNumber(cursor.getCount()).setStyle(inboxStyle) .setColor(mContext.getResources().getColor(R.color.md_primary)) // .addAction(R.drawable.ic_action_content_clear_dark, getContext().getString(R.string.skip), skipPending) // .addAction(R.drawable.ic_action_done_dark, getContext().getString(R.string.enter), enterPending) .build(); // notify notificationManager.cancel(ID_NOTIFICATION); notificationManager.notify(ID_NOTIFICATION, notification); } catch (Exception e) { Timber.e(e, "showing notification for recurring transaction"); } }
From source file:vn.easycare.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *///from w w w.ja va 2 s . c om private void generateNotification(Context context, String message) { int icon = R.drawable.ic_launcher; long when = 0;//System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, NotificationReceivingActivity.class); // set intent so it does not start a new activity // notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent intent = PendingIntent.getActivity(context, (int) when, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, title, message, intent); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; notification.flags |= Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL; notificationManager.notify((int) when, notification); }
From source file:com.playpalgames.app.GcmIntentService.java
private void sendNotification(String notificationMessage, String command) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = new Intent(this.getApplicationContext(), StartActivity_.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.putExtra("COMMAND", command); intent.setAction(Long.toString(System.currentTimeMillis())); PendingIntent contentIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ball) .setContentTitle("Penalty!").setAutoCancel(true) .setStyle(new NotificationCompat.BigTextStyle().bigText(notificationMessage)) .setContentText(notificationMessage); mBuilder.setContentIntent(contentIntent); Notification note = mBuilder.build(); note.defaults |= Notification.DEFAULT_VIBRATE; note.defaults |= Notification.DEFAULT_SOUND; mNotificationManager.notify(NOTIFICATION_ID, note); }
From source file:com.rossier.shclechelles.service.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.// w ww . j a v a2 s . com */ private void sendNotification(String from, String message) { Gson gson = new GsonBuilder().create(); String messageUTF8 = ""; try { messageUTF8 = new String(message.getBytes(), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.i("MyGCMListenerService", message); Log.i("MyGCMListenerService", messageUTF8); if (messageUTF8 == "") return; MatchNotification match = gson.fromJson(messageUTF8, MatchNotification.class); Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); int icon = R.drawable.ic_launcher_shc; long when = System.currentTimeMillis(); // Notification notification = new Notification(icon, "Nouveaux rsultats", when); Notification notification = new Notification.Builder(this.getBaseContext()) .setContentText("Nouveaux rsultats").setSmallIcon(icon).setWhen(when).build(); NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.match_notif_layout); contentView.setTextViewText(R.id.notif_team_home, match.getTeam_home()); contentView.setTextViewText(R.id.notif_team_away, match.getTeam_away()); contentView.setTextViewText(R.id.notif_result_home, match.getResult_home() + ""); contentView.setTextViewText(R.id.notif_result_away, match.getResult_away() + ""); contentView.setTextViewText(R.id.notif_ligue, match.getLigue()); contentView.setImageViewResource(R.id.notif_team_loc_logo, Utils.getLogo(match.getTeam_home())); contentView.setImageViewResource(R.id.notif_team_away_logo, Utils.getLogo(match.getTeam_away())); notification.contentView = contentView; Intent notificationIntent = new Intent(this, MainActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.contentIntent = contentIntent; //notification.flags |= Notification.FLAG_ONGOING_EVENT; //Do not clear the notification notification.defaults |= Notification.DEFAULT_LIGHTS; // LED notification.defaults |= Notification.DEFAULT_VIBRATE; //Vibration notification.defaults |= Notification.DEFAULT_SOUND; // Sound //get topics name String[] topic = from.split("/"); mNotificationManager.notify(topic[2].hashCode(), notification); }
From source file:uk.org.rivernile.edinburghbustracker.android.alerts.ProximityAlertReceiver.java
/** * {@inheritDoc}/* w w w . ja v a 2 s . co m*/ */ @Override public void onReceive(final Context context, final Intent intent) { final SettingsDatabase db = SettingsDatabase.getInstance(context); final String stopCode = intent.getStringExtra(ARG_STOPCODE); // Make sure the alert is still active to remain relevant. if (!db.isActiveProximityAlert(stopCode)) return; final String stopName = BusStopDatabase.getInstance(context).getNameForBusStop(stopCode); final NotificationManager notMan = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); final LocationManager locMan = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); // Delete the alert from the database. db.deleteAllAlertsOfType(SettingsDatabase.ALERTS_TYPE_PROXIMITY); // Make sure the LocationManager no longer checks for this proximity. final PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0); locMan.removeProximityAlert(pi); final String title = context.getString(R.string.proxreceiver_notification_title, stopName); final String summary = context.getString(R.string.proxreceiver_notification_summary, intent.getIntExtra(ARG_DISTANCE, 0), stopName); final String ticker = context.getString(R.string.proxreceiver_notification_ticker, stopName); final SharedPreferences sp = context.getSharedPreferences(PreferencesActivity.PREF_FILE, 0); // Create the notification. final NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context); notifBuilder.setAutoCancel(true); notifBuilder.setSmallIcon(R.drawable.ic_status_bus); notifBuilder.setTicker(ticker); notifBuilder.setContentTitle(title); notifBuilder.setContentText(summary); // Support for Jelly Bean notifications. notifBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(summary)); final Intent launchIntent; if (GenericUtils.isGoogleMapsAvailable(context)) { // The Intent which launches the bus stop map at the selected stop. launchIntent = new Intent(context, BusStopMapActivity.class); launchIntent.putExtra(BusStopMapActivity.ARG_STOPCODE, stopCode); } else { launchIntent = new Intent(context, BusStopDetailsActivity.class); launchIntent.putExtra(BusStopDetailsActivity.ARG_STOPCODE, stopCode); } notifBuilder .setContentIntent(PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_ONE_SHOT)); final Notification n = notifBuilder.build(); if (sp.getBoolean(PreferencesActivity.PREF_ALERT_SOUND, true)) n.defaults |= Notification.DEFAULT_SOUND; if (sp.getBoolean(PreferencesActivity.PREF_ALERT_VIBRATE, true)) n.defaults |= Notification.DEFAULT_VIBRATE; if (sp.getBoolean(PreferencesActivity.PREF_ALERT_LED, true)) { n.defaults |= Notification.DEFAULT_LIGHTS; n.flags |= Notification.FLAG_SHOW_LIGHTS; } // Send the notification to the UI. notMan.notify(ALERT_ID, n); }
From source file:com.near.chimerarevo.services.NewsService.java
private void createNotification() { if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean("notification_pref", true)) return;/* w w w . ja v a 2 s . co m*/ Intent intent = new Intent(this, MainActivity.class); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0); NotificationCompat.BigTextStyle bigStyle = new NotificationCompat.BigTextStyle(); bigStyle.bigText(getResources().getString(R.string.text_newposts_summary)); bigStyle.setBigContentTitle(getResources().getString(R.string.app_name)); NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender() .setContentIcon(R.drawable.ic_logo_cr_mini).setHintHideIcon(true); Notification n = new NotificationCompat.Builder(this) .setContentTitle(getResources().getString(R.string.app_name)) .setContentText(getResources().getString(R.string.text_newposts_summary)) .setSmallIcon(R.drawable.ic_logo_cr_mini).setContentIntent(pIntent).extend(wearableExtender) .setAutoCancel(true).build(); if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("notification_vibrate_pref", true)) n.defaults |= Notification.DEFAULT_VIBRATE; if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("notification_sound_pref", true)) n.defaults |= Notification.DEFAULT_SOUND; if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("notification_light_pref", true)) { n.ledARGB = getLEDColor(); n.ledOnMS = 300; n.ledOffMS = 1000; n.flags |= Notification.FLAG_SHOW_LIGHTS; } NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.notify(0, n); }