本文整理汇总了Java中android.app.Notification.DEFAULT_VIBRATE属性的典型用法代码示例。如果您正苦于以下问题:Java Notification.DEFAULT_VIBRATE属性的具体用法?Java Notification.DEFAULT_VIBRATE怎么用?Java Notification.DEFAULT_VIBRATE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.app.Notification
的用法示例。
在下文中一共展示了Notification.DEFAULT_VIBRATE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCustomNotification
public void addCustomNotification(Intent onClickIntent, int iconResourceID, String title, String message, boolean isOngoingEvent) {
PendingIntent notifContentIntent = PendingIntent.getActivity(this, 0, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Bitmap bm = null;
try {
bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
} catch (Exception e) {
}
mCustomNotif = Compatibility.createNotification(this, title, message, iconResourceID, 0, bm, notifContentIntent, isOngoingEvent,notifcationsPriority);
mCustomNotif.defaults |= Notification.DEFAULT_VIBRATE;
mCustomNotif.defaults |= Notification.DEFAULT_SOUND;
mCustomNotif.defaults |= Notification.DEFAULT_LIGHTS;
notifyWrapper(CUSTOM_NOTIF_ID, mCustomNotif);
}
示例2: configOtherPushNotification
public static void configOtherPushNotification(Notification notification) {
int mask = Settings.get()
.notifications()
.getOtherNotificationMask();
if (Utils.hasFlag(mask, ISettings.INotificationSettings.FLAG_LED)) {
notification.ledARGB = 0xFF0000FF;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.ledOnMS = 100;
notification.ledOffMS = 1000;
}
if (Utils.hasFlag(mask, ISettings.INotificationSettings.FLAG_VIBRO))
notification.defaults |= Notification.DEFAULT_VIBRATE;
if (Utils.hasFlag(mask, ISettings.INotificationSettings.FLAG_SOUND)) {
notification.sound = Settings.get()
.notifications()
.getFeedbackRingtoneUri();
}
}
示例3: showCzNotify
/**
* 显示常驻通知栏
*/
public void showCzNotify(String title, String content, String ticker, int notifyId) {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
// //PendingIntent 跳转动作
// PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,Intent.getIntent(), 0);
mBuilder.setSmallIcon(R.mipmap.ic_launcher)
.setTicker(ticker)
.setContentTitle(title)
.setContentText(content);
// .setContentIntent(pendingIntent);
Notification mNotification = mBuilder.build();
//设置通知 消息 图标
mNotification.icon = R.mipmap.ic_launcher;
//在通知栏上点击此通知后自动清除此通知
mNotification.flags = Notification.FLAG_ONGOING_EVENT;//FLAG_ONGOING_EVENT 在顶部常驻,可以调用下面的清除方法去除 FLAG_AUTO_CANCEL 点击和清理可以去调
//设置显示通知时的默认的发声、震动、Light效果
mNotification.defaults = Notification.DEFAULT_VIBRATE;
//设置发出消息的内容
// mNotification.tickerText = "通知来了";
//设置发出通知的时间
mNotification.when = System.currentTimeMillis();
// mNotification.flags = Notification.FLAG_AUTO_CANCEL; //在通知栏上点击此通知后自动清除此通知
// mNotification.setLatestEventInfo(this, "常驻测试", "使用cancel()方法才可以把我去掉哦", null); //设置详细的信息 ,这个方法现在已经不用了
mNotificationManager.notify(notifyId, mNotification);
}
示例4: makeNotification
private Notification makeNotification(PendingIntent pendingIntent, String title, String content, String tickerText,
int iconId, boolean ring, boolean vibrate) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle(title)
.setContentText(content)
.setAutoCancel(true)
.setContentIntent(pendingIntent)
.setTicker(tickerText)
.setSmallIcon(iconId);
int defaults = Notification.DEFAULT_LIGHTS;
if (vibrate) {
defaults |= Notification.DEFAULT_VIBRATE;
}
if (ring) {
defaults |= Notification.DEFAULT_SOUND;
}
builder.setDefaults(defaults);
return builder.build();
}
示例5: makeNotification
private Notification makeNotification(PendingIntent pendingIntent, String title, String content, String tickerText,
int iconId, boolean ring, boolean vibrate) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle(title)
.setContentText(content)
.setTicker(content)
.setAutoCancel(true)
.setContentIntent(pendingIntent)
.setTicker(tickerText)
.setLargeIcon(largeIconId())
.setSmallIcon(iconId);
int defaults = Notification.DEFAULT_LIGHTS;
if (vibrate) {
defaults |= Notification.DEFAULT_VIBRATE;
}
if (ring) {
defaults |= Notification.DEFAULT_SOUND;
}
builder.setDefaults(defaults);
return builder.build();
}
示例6: testNotificationAdapter
@Test
public void testNotificationAdapter() {
final String NOTIFICATION_TEXT = "adapter-text";
final String NOTIFICATION_TITLE = "adapter-title";
final long TIMEOUT = 5000;
Context appContext = InstrumentationRegistry.getTargetContext();
RemoteViews contentView = new RemoteViews("cn.dreamtobe.toolset.test", R.layout.custom_layout);
contentView.setTextViewText(R.id.title, NOTIFICATION_TITLE);
contentView.setTextViewText(R.id.text, NOTIFICATION_TEXT);
// Fix the Notification-Style problem ---------------
// Set the default title style color to title view.
contentView.setTextColor(R.id.title, NotificationAdapter.getTitleColor(appContext));
// Set the default title style size to title view
contentView.setTextViewTextSize(R.id.title, COMPLEX_UNIT_PX, NotificationAdapter.getTitleSize(appContext));
// Set the default text style color to text view
contentView.setTextColor(R.id.text, NotificationAdapter.getTextColor(appContext));
// Set the default text style size to text view
contentView.setTextViewTextSize(R.id.text, COMPLEX_UNIT_PX, NotificationAdapter.getTextSize(appContext));
// End fix the Notification-Style problem ---------------
Notification notification = new Notification();
notification.icon = R.drawable.ic_launcher;
notification.contentView = contentView;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
NotificationManager notifyMgr =
(NotificationManager) appContext.getSystemService(NOTIFICATION_SERVICE);
notifyMgr.notify(1, notification);
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
device.openNotification();
device.wait(Until.hasObject(By.text(NOTIFICATION_TITLE)), TIMEOUT);
}
示例7: isPassiveNotification
private boolean isPassiveNotification(Notification notification) {
// If notification specified either default vibration or default sound, mark it as non-passive
if ((notification.defaults & (Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND)) != 0) {
return false;
}
return getVibrationLength(notification.vibrate) == 0 && notification.sound == null;
}
示例8: showMessage
/**
* 通知栏提醒
* @param messageItem 消息信息
*/
@SuppressWarnings("deprecation")
private void showMessage(ChatMessageItem messageItem) {
SettingSPUtil setSP = MyApp.getInstance().getSettingSPUtil();
if (!setSP.isChatNotiOnBar()){
return;
}
String messageContent = messageItem.getNickName()+":"+messageItem.getMessage();
MyApp.getInstance().setNewMsgCount(MyApp.getInstance().getNewMsgCount()+1); //数目+1
Notification notification = new Notification(R.drawable.ic_launcher,messageContent, System.currentTimeMillis());
notification.flags = Notification.FLAG_AUTO_CANCEL;
if (setSP.isChatRing()){
// 设置默认声音
notification.defaults |= Notification.DEFAULT_SOUND;
}
if (setSP.isChatVibrate()){
// 设定震动(需加VIBRATE权限)
notification.defaults |= Notification.DEFAULT_VIBRATE;
}
Intent intent = new Intent(MyApp.getInstance(),ChatRoomAty.class);
intent.putExtra("TrainId", messageItem.getTrainId());
PendingIntent contentIntent = PendingIntent.getActivity(MyApp.getInstance(), 0, intent, 0);
String contentText = null;
if(MyApp.getInstance().getNewMsgCount()==1){
contentText = messageContent;
}else{
contentText = MyApp.getInstance().getNewMsgCount()+"条未读消息";
}
notification.setLatestEventInfo(MyApp.getInstance(), "车友聊天室", contentText, contentIntent);
NotificationManager manage = (NotificationManager) MyApp.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
manage.notify(NOTIFICATION_ID, notification);
}
示例9: applyVibration
private void applyVibration(Notification notification) {
if (vibration == VibrationPattern.OFF) {
notification.vibrate = null;
} else if (vibration == VibrationPattern.DEFAULT) {
notification.defaults |= Notification.DEFAULT_VIBRATE;
} else {
notification.vibrate = vibration.pattern;
}
}
示例10: sendNotification
private void sendNotification(String messageTitle, String messageBody) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT);
if (messageTitle == null) messageTitle = "";
if (messageBody == null) messageBody = "";
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setLights(Color.WHITE, 1000, 1000)
.setContentTitle(messageTitle.isEmpty() ? getString(R.string.app_name) : messageTitle)
.setContentText(messageBody)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.setSmallIcon(R.drawable.ic_fcm_notification)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
notificationBuilder.setPriority(Notification.PRIORITY_DEFAULT);
NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
bigTextStyle.setBigContentTitle(messageTitle.isEmpty() ? getString(R.string.app_name) : messageTitle);
bigTextStyle.bigText(messageBody);
notificationBuilder.setStyle(bigTextStyle);
}
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notificationToShow = notificationBuilder.build();
notificationToShow.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(notificationCount++, notificationToShow);
}
示例11: setBuilder
/**
* 设置builder的信息,在用大文本时会用到这个
*
* @param pendingIntent
* @param smallIcon
* @param ticker
*/
private void setBuilder(PendingIntent pendingIntent, int smallIcon, String ticker, boolean sound, boolean vibrate, boolean lights) {
nBuilder = new Notification.Builder(mContext);
// 如果当前Activity启动在前台,则不开启新的Activity。
// intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// PendingIntent pIntent = PendingIntent.getActivity(mContext,
// requestCode, intent, FLAG);
nBuilder.setContentIntent(pendingIntent);
nBuilder.setSmallIcon(smallIcon);
nBuilder.setTicker(ticker);
nBuilder.setWhen(System.currentTimeMillis());
nBuilder.setPriority(Notification.PRIORITY_MAX);
int defaults = 0;
if (sound) {
defaults |= Notification.DEFAULT_SOUND;
}
if (vibrate) {
defaults |= Notification.DEFAULT_VIBRATE;
}
if (lights) {
defaults |= Notification.DEFAULT_LIGHTS;
}
nBuilder.setDefaults(defaults);
}
示例12: setCompatBuilder
/**
* 设置在顶部通知栏中的各种信息
*
* @param pendingIntent
* @param smallIcon
* @param ticker
* @param pendingIntentCancel
*/
private void setCompatBuilder(PendingIntent pendingIntent, int smallIcon, String ticker,
String title, String content, boolean sound, boolean vibrate, boolean lights, PendingIntent pendingIntentCancel) {
// // 如果当前Activity启动在前台,则不开启新的Activity。
// intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// // 当设置下面PendingIntent.FLAG_UPDATE_CURRENT这个参数的时候,常常使得点击通知栏没效果,你需要给notification设置一个独一无二的requestCode
// // 将Intent封装进PendingIntent中,点击通知的消息后,就会启动对应的程序
// PendingIntent pIntent = PendingIntent.getActivity(mContext,
// requestCode, intent, FLAG);
cBuilder.setContentIntent(pendingIntent);// 该通知要启动的Intent
cBuilder.setSmallIcon(smallIcon);// 设置顶部状态栏的小图标
cBuilder.setTicker(ticker);// 在顶部状态栏中的提示信息
cBuilder.setContentTitle(title);// 设置通知中心的标题
cBuilder.setContentText(content);// 设置通知中心中的内容
cBuilder.setWhen(System.currentTimeMillis());
/*
* 将AutoCancel设为true后,当你点击通知栏的notification后,它会自动被取消消失,
* 不设置的话点击消息后也不清除,但可以滑动删除
*/
cBuilder.setAutoCancel(true);
// 将Ongoing设为true 那么notification将不能滑动删除
// notifyBuilder.setOngoing(true);
/*
* 从Android4.1开始,可以通过以下方法,设置notification的优先级,
* 优先级越高的,通知排的越靠前,优先级低的,不会在手机最顶部的状态栏显示图标
*/
cBuilder.setPriority(NotificationCompat.PRIORITY_MAX);
/*
* Notification.DEFAULT_ALL:铃声、闪光、震动均系统默认。
* Notification.DEFAULT_SOUND:系统默认铃声。
* Notification.DEFAULT_VIBRATE:系统默认震动。
* Notification.DEFAULT_LIGHTS:系统默认闪光。
* notifyBuilder.setDefaults(Notification.DEFAULT_ALL);
*/
int defaults = 0;
cBuilder.setDeleteIntent(pendingIntentCancel);
if (sound) {
defaults |= Notification.DEFAULT_SOUND;
}
if (vibrate) {
defaults |= Notification.DEFAULT_VIBRATE;
}
if (lights) {
defaults |= Notification.DEFAULT_LIGHTS;
}
cBuilder.setDefaults(defaults);
}
示例13: setCompatBuilder
/**
* 设置在顶部通知栏中的各种信息
* @param pendingIntent
* @param smallIcon
* @param ticker
* @param pendingIntentCancel
*/
private void setCompatBuilder(PendingIntent pendingIntent, int smallIcon, String ticker,
String title, String content, boolean sound, boolean vibrate, boolean lights, PendingIntent pendingIntentCancel) {
// // 如果当前Activity启动在前台,则不开启新的Activity。
// intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// // 当设置下面PendingIntent.FLAG_UPDATE_CURRENT这个参数的时候,常常使得点击通知栏没效果,你需要给notification设置一个独一无二的requestCode
// // 将Intent封装进PendingIntent中,点击通知的消息后,就会启动对应的程序
// PendingIntent pIntent = PendingIntent.getActivity(mContext,
// requestCode, intent, FLAG);
cBuilder.setContentIntent(pendingIntent);// 该通知要启动的Intent
cBuilder.setSmallIcon(smallIcon);// 设置顶部状态栏的小图标
cBuilder.setTicker(ticker);// 在顶部状态栏中的提示信息
cBuilder.setContentTitle(title);// 设置通知中心的标题
cBuilder.setContentText(content);// 设置通知中心中的内容
cBuilder.setWhen(System.currentTimeMillis());
/*
* 将AutoCancel设为true后,当你点击通知栏的notification后,它会自动被取消消失,
* 不设置的话点击消息后也不清除,但可以滑动删除
*/
cBuilder.setAutoCancel(true);
// 将Ongoing设为true 那么notification将不能滑动删除
// notifyBuilder.setOngoing(true);
/*
* 从Android4.1开始,可以通过以下方法,设置notification的优先级,
* 优先级越高的,通知排的越靠前,优先级低的,不会在手机最顶部的状态栏显示图标
*/
cBuilder.setPriority(NotificationCompat.PRIORITY_MAX);
/*
* Notification.DEFAULT_ALL:铃声、闪光、震动均系统默认。
* Notification.DEFAULT_SOUND:系统默认铃声。
* Notification.DEFAULT_VIBRATE:系统默认震动。
* Notification.DEFAULT_LIGHTS:系统默认闪光。
* notifyBuilder.setDefaults(Notification.DEFAULT_ALL);
*/
int defaults = 0;
cBuilder.setDeleteIntent(pendingIntentCancel);
if (sound) {
defaults |= Notification.DEFAULT_SOUND;
}
if (vibrate) {
defaults |= Notification.DEFAULT_VIBRATE;
}
if (lights) {
defaults |= Notification.DEFAULT_LIGHTS;
}
cBuilder.setDefaults(defaults);
}
示例14: createNotification
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressWarnings("deprecation")
public static void createNotification(Context context, Class<?> cls, String title, String content, String ticker, int id){
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent detailIntent = context.getPackageManager().getLaunchIntentForPackage(CommonUtils
.getPackageName(context));
detailIntent.setPackage((String)null);
detailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent2 = PendingIntent.getActivity(context, 0,
detailIntent, 0);
int smallicon = SharedPreferencesUtil.getIntData(context, ZhiChiConstant
.SOBOT_NOTIFICATION_SMALL_ICON, ResourceUtils.getIdByName(context, "drawable", "sobot_logo_small_icon"));
int largeicon = SharedPreferencesUtil.getIntData(context, ZhiChiConstant
.SOBOT_NOTIFICATION_LARGE_ICON, ResourceUtils.getIdByName(context, "drawable", "sobot_logo_icon"));
// 通过Notification.Builder来创建通知,注意API Level
// API11之后才支持
// int smallicon = ResourceUtils.getIdByName(context, "drawable", "sobot_logo_small_icon");
// int largeicon = ResourceUtils.getIdByName(context, "drawable", "sobot_logo_icon");
BitmapDrawable bd = (BitmapDrawable) context.getResources().getDrawable(largeicon);
Bitmap bitmap = bd.getBitmap();
Notification notify2 = new Notification.Builder(context)
.setSmallIcon(smallicon) // 设置状态栏中的小图片,尺寸一般建议在24×24,这个图片同样也是在下拉状态栏中所显示,如果在那里需要更换更大的图片,可以使用setLargeIcon(Bitmap
// icon)
.setLargeIcon(bitmap)
.setTicker(ticker)// 设置在status
// bar上显示的提示文字
.setContentTitle(title)// 设置在下拉status
// bar后Activity,本例子中的NotififyMessage的TextView中显示的标题
.setContentText(content)// TextView中显示的详细内容
.setContentIntent(pendingIntent2) // 关联PendingIntent
//.setNumber(1) // 在TextView的右方显示的数字,可放大图片看,在最右侧。这个number同时也起到一个序列号的左右,如果多个触发多个通知(同一ID),可以指定显示哪一个。
.getNotification(); // 需要注意build()是在API level
// 16及之后增加的,在API11中可以使用getNotificatin()来代替
notify2.flags |= Notification.FLAG_AUTO_CANCEL;
/*String ss = SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_NOTIFICATION,"true");
LogUtils.i("notification--------" + ss);
if(SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_NOTIFICATION,"true").equals("true")) {
LogUtils.i("notification--------info--open" + ss);
if((SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_VIBRATE,"true").equals("true"))
&& (SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_SOUND,"true").equals("true"))){
notify2.defaults = Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND;
LogUtils.i("notification--------all--open" + ss);
}else if(SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_SOUND,"true").equals("true")) {
notify2.defaults = Notification.DEFAULT_SOUND;
LogUtils.i("notification--------sound--open" + ss);
}else if(SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_VIBRATE,"true").equals("true")) {
notify2.defaults = Notification.DEFAULT_VIBRATE;
LogUtils.i("notification--------shake--open" + ss);
}
}*/
notify2.defaults = Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND;
manager.notify(id, notify2);
}
示例15: sendNotificationSys
private static void sendNotificationSys(Context context, String msgTitle, String msgBody, String msgId, int notifyId, int msgCount)
{
Intent intent = new Intent(context, CurrentUserActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle msgListBundle = new Bundle();
msgListBundle.putString("userName", msgTitle);
msgListBundle.putString("userId", msgId);
msgListBundle.putString("userType", SYS);
msgListBundle.putString("userMessage", msgBody);
msgListBundle.putString("userTime", getCurTime());
msgListBundle.putString("senderType", "1");
msgListBundle.putInt("notifyId", notifyId);
msgListBundle.putString("msgCount", String.valueOf(msgCount));
intent.putExtras(msgListBundle);
PendingIntent pendingIntent = PendingIntent.getActivity(context, notifyId /* Request code */, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
Bundle msgNotifyBundle = new Bundle();
msgNotifyBundle.putInt("notifyId", notifyId);
//通知清除事件
Intent intentCancel = new Intent(context, SysNotificationBroadcastReceiver.class);
intentCancel.setAction("sys_notification_cancelled");
intentCancel.putExtras(msgNotifyBundle);
PendingIntent pendingIntentCancel = PendingIntent.getBroadcast(context, notifyId, intentCancel, PendingIntent.FLAG_ONE_SHOT);
StringBuffer tickerSys = new StringBuffer();
tickerSys.append(msgTitle);
tickerSys.append("\r\n");
tickerSys.append(msgBody);
if (msgCount != 1)
{
msgTitle = msgTitle + "(" + msgCount + "条新消息)";
}
int smallIcon;
Bitmap largeIcon;
switch (msgId) {
case "1":
smallIcon = R.drawable.qq_notification;
largeIcon = BitmapFactory.decodeResource(context.getResources(), R.mipmap.qq);
break;
case "2":
smallIcon = R.drawable.weixin_notification;
largeIcon = BitmapFactory.decodeResource(context.getResources(), R.mipmap.weixin);
break;
default:
smallIcon = R.drawable.sys_notification;
largeIcon = BitmapFactory.decodeResource(context.getResources(), R.mipmap.sys);
}
int defaults = 0;
defaults |= Notification.DEFAULT_LIGHTS;
defaults |= Notification.DEFAULT_VIBRATE;
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(smallIcon)
.setLargeIcon(largeIcon)
.setTicker(tickerSys)
.setContentTitle(msgTitle)
.setStyle(new NotificationCompat.BigTextStyle() // 设置通知样式为大型文本样式
.bigText(msgBody))
.setContentText(msgBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setDefaults(defaults)
.setContentIntent(pendingIntent)
.setDeleteIntent(pendingIntentCancel);
notificationBuilder.setPriority(Notification.PRIORITY_HIGH); //自动弹出通知
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notifyId, notificationBuilder.build());
}