android Notification 通知封装
来源:互联网 发布:嗅探软件下载 编辑:程序博客网 时间:2024/05/01 18:37
public class NotificationUtils { private static NotificationManager mNotificationManager; private static Notification notification; /** * 创建通知, * 请在调用此方法时开启子线程 * * @param context 上下文 * @param icon 通知图片 * @param tickerText 通知未拉开的内容 * @param title 通知标题 * @param content 通知主内容 * @param intent 意图 * @param id * @param time 控制线程睡眠时间 */ public static void createNotif(Context context, int icon, String tickerText, String title, String content, Intent intent, int id, long time) { intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setAction(Intent.ACTION_MAIN); //intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); PendingIntent pendingIntent = PendingIntent.getActivity(context, id, intent, PendingIntent.FLAG_UPDATE_CURRENT); mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context); mBuilder.setContentTitle(title) .setContentText(content) .setContentIntent(pendingIntent) .setTicker(tickerText) .setWhen(System.currentTimeMillis()) .setPriority(Notification.PRIORITY_DEFAULT) .setOngoing(false) .setAutoCancel(true) .setDefaults(Notification.DEFAULT_SOUND) .setSmallIcon(icon); notification = mBuilder.build(); notification.flags = Notification.FLAG_ONGOING_EVENT; notification.flags = Notification.FLAG_AUTO_CANCEL; mNotificationManager.notify(id, notification); try { Thread.sleep(time); } catch (InterruptedException e) { e.printStackTrace(); } }}
0 0
- android Notification 通知封装
- Android Notification 通知封装成工具类
- Notification---Android Notification通知详解
- 定制android通知(Notification)
- 定制android通知(Notification)
- android之Notification通知
- android之Notification通知
- Android 消息通知-Notification
- Android Notification通知详解
- android之Notification通知
- Android通知Notification
- Android 通知栏 Notification
- Android Notification通知详解
- android之Notification通知
- Android 状态栏通知Notification
- android之Notification通知
- android之Notification通知
- Android Notification通知详解
- java学习笔记之异常
- MTK 平台基带原理
- 使用Ionic.Zip后文件夹过多的解决办法?
- 搭建网站常见返回码40X 50X等错误的原因及解决方案
- 01背包问题(回溯算法实现)
- android Notification 通知封装
- 【转载】迅为4412开发板实验LEDS驱动一
- Cocos2d-js cc.game项目启动
- window安装webPageTest之环境搭建
- 动态规划的详细解析(01背包问题)
- Histogram of Oriented Gridients(HOG) 方向梯度直方图
- Matryoshka题解
- Qt Multimedia--- note
- 01背包问题