Android notification

来源:互联网 发布:淘宝流量高峰期查询 编辑:程序博客网 时间:2024/05/18 01:56

NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);// 实例notification 表示通知的具体内容Notification notification = new Notification(R.drawable.ic_launcher,"我是一个通知", System.currentTimeMillis());// 点击通知后依然显示,另外还可以设置通知不能被清除等等notification.flags = Notification.FLAG_INSISTENT;// 点击这个通知后会转到电话拨打Intent intent = new Intent();intent.setAction(Intent.ACTION_CALL);intent.setData(Uri.parse("tel:123"));PendingIntent contentIntent = PendingIntent.getActivity(this, 0,intent, 0);notification.setLatestEventInfo(this, "我是通知的标题", "我是通知的文本",contentIntent);// 这种写法只能在版本3.0以上才可以使用// Notification.Builder builder = new Builder(this);// builder.setContentTitle("我是通知的标题")// .setContentText("我是通知的文本")// .setSmallIcon(R.drawable.ic_launcher)// .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher));// Notification notification = builder.build();manager.notify(0, notification);

0 0
原创粉丝点击