Android 使用大号的通知
2016-07-27 12:05
323 查看
Notification 一般是两个形式出现的:
一种是普通形式
一种是bigView形式:
但是 big View 只在Notification扩展的时候显示,也就是说, 只在 此Notification 在drawer的最上面,或者是用户点击之后,才会扩展。
使用 BigView 的目的在于,让用户不需要打开 应用,就可以完成交互
添加到你的通知中去
一种是普通形式
一种是bigView形式:
但是 big View 只在Notification扩展的时候显示,也就是说, 只在 此Notification 在drawer的最上面,或者是用户点击之后,才会扩展。
使用 BigView 的目的在于,让用户不需要打开 应用,就可以完成交互
构造一个Bigview (闹钟样例)
构造 忽略 和 稍后 两个将会出现在 bigview中的按钮Intent dismissIntent = new Intent(this, PingService.class); dismissIntent.setAction(CommonConstants.ACTION_DISMISS); PendingIntent piDismiss = PendingIntent.getService(this, 0, dismissIntent, 0); Intent snoozeIntent = new Intent(this, PingService.class); snoozeIntent.setAction(CommonConstants.ACTION_SNOOZE); PendingIntent piSnooze = PendingIntent.getService(this, 0, snoozeIntent, 0);
添加到你的通知中去
// Constructs the Builder object. NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_notification) .setContentTitle(getString(R.string.notification)) .setContentText(getString(R.string.ping)) .setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission /* * Sets the big view "big text" style and supplies the * text (the user's reminder message) that will be displayed * in the detail area of the expanded notification. * These calls are ignored by the support library for * pre-4.1 devices. */ .setStyle(new NotificationCompat.BigTextStyle() .bigText(msg)) .addAction (R.drawable.ic_stat_dismiss, getString(R.string.dismiss), piDismiss) .addAction (R.drawable.ic_stat_snooze, getString(R.string.snooze), piSnooze);
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories