notification的创建及应用
之前我用了button.setonclicklistener来获取一个点击事件,但是在new notificationcompat.builder是会报一个没有定义的错误。这种点击事件的方式就不会报那种错误了。
public class MainActivity extends Activity implements View.OnClickListener { private Button sendnotice; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); sendnotice = (Button) findViewById(id.send_notice);
sendnotice.setOnClickListener(this);
} @Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.send_notice:
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle("锋少来通知了") //设置标题
.setContentText("去哪里玩啊") //内容
.setWhen(System.currentTimeMillis()) //时间
.setSmallIcon(R.drawable.ic_launcher) //小图片
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)) //大图片
.build();
manager.notify(,notification);
break; }
}
}
notification的创建及应用的更多相关文章
- Notification通知创建
Notification通知创建 由于通知是一个远程视图,所以创建通知在状态栏显示需要用到三个主要的对象: 一.PendingIntent对象,用来承载Intent对象的,Intent对象主要是定义通 ...
- Android Wear 开发入门——怎样创建一个手机与可穿戴设备关联的通知(Notification)
创建通知 为了创建在手机与可穿戴设备中都能展现的通知,能够使用 NotificationCompat.Builder.通过该类创建的通知,系统会处理该通知是否展如今手机或者穿戴设备中. 导入必要的类库 ...
- Android Notification 详解(一)——基本操作
Android Notification 详解(一)--基本操作 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/Notification 文中如有纰 ...
- Android Notification 详解——基本操作
Android Notification 详解 版权声明:本文为博主原创文章,未经博主允许不得转载. 前几天项目中有用到 Android 通知相关的内容,索性把 Android Notificatio ...
- Android notification的使用
notification出现在通知栏中的提示,特别是在4.0以后改进了不少,这里讲得都是基于4.0及4.1以后的. 分类: 1.普通Notification 2.大布局Notification 图1 ...
- notification的使用
示例: NotificationManager nm = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); No ...
- Notification
一:普通Notification 1.内容标题setContentTitle(...) 2.大图标setLargeIcon(Bitmap) 3.内容setContentText(...) 4.内容附加 ...
- android Notification 的使用
最近一直在研究 android ,并一边研究一边做应用.其中遇到了把程序通知常驻在 Notification 栏,并且不能被 clear 掉(就像android QQ一样)的问题.经过研究实现了其功能 ...
- Android 和iOS 创建本地通知
1 Android 中的发送本地通知的逻辑如下 先实例化Notification.Builder,再用builder创建出具体的Notification,创建时要指定好启动用的PendingInten ...
随机推荐
- java map典型排序
List<Map.Entry<TbDiseases, Double>> list = new ArrayList<Map.Entry<TbDiseases,Doub ...
- 01 - spring mvc 概述及配置DispatcherServlet
1.Spring mvc 基于model2实现,整体框架流程如(图片来自百度): ①web容器接收到http请求,若匹配DispatcherServlet的请求映射路径(web.xml),则容器会交给 ...
- 程序员:统治世界or修复bug?
程序员:统治世界or修复bug? 时至今日,我们依然生活在一个市场和技术受到高度崇拜的世界里,但是历史演化的规律提醒着我们:当一个东西开始成为社会崇拜的对象时,其中暗藏的不利因素将悄然的进行着.有人认 ...
- 对Java平台的理解
1) Java是一种面向对象的语言(封装,继承,多态),最显著的特性有两个方面: ----书写一次,到处运行(Write once,run anywhere) 能够非常容易的获得跨平台的能力 --- ...
- linux在线安装telnet
平常在调试机器网络互通的时候使用到telnet,新机器一般没安装相应命令,需要我们手工安装. 下面是在线安装的方法,使用以下命令即可完成安装: yum install telnet
- c++编译时打印宏定义
#pragma message("this is message") #pragma message只能打印字符串,如果想打印任何宏定义可使用: #define PRINT_MAC ...
- CONFLICT (modify delete)冲突修复
Demo git:(test) git merge feature CONFLICT (modify/delete): path/to/path/config.inc.php deleted in H ...
- ubuntu16.04深度学习环境的配置【转】
本文转载自:https://my.oschina.net/u/3837179/blog/1920756 在ubuntu中配置GPU的深度学习环境相较于win问题要多很多,这几天琢磨了一下Ubuntu下 ...
- CentOS7.2 安装Tomcat
Centos默认安装JDK 现在要删除旧版本的jdk,安装新版本jdk 查看现有jdk: [root@localhost 桌面]# rpm -qa | grep jdk java-1.8.0-open ...
- 试着用React写项目-利用react-router解决跳转路由等问题(一)
转载请注明出处:王亟亟的大牛之路 继续本周的大方向,继续学习React,昨天把简单的hi all内容呈现出来后,今天研究如何多页面或者实现页面嵌套, 开始今天的内容前老规矩,先安利:https://g ...