[android]_[Notication的使用]

相信多数人都知道安卓上的通知,这原本是安卓系统的一大特点,早期iOS和wp还没有。

一、创建通知的步骤:

1.创建NotificationManager

2.创建Notification

3.调用NotificationManager的方法notify()产生通知

代码如下:

NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification.Builder(this)
		.setContentTitle("This is content title")
		.setContentText("This is ticker text")
		.setSmallIcon(R.mipmap.ic_launcher)
		.build();
manager.notify(1, notification);

二、通知的其它属性

1.点击通知框弹出窗口

2.弹出窗口后关闭通知

例子完整代码:

MainActivity:

package com.example.administrator.notification;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.C
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值