Android开发之使用通知栏显示提醒信息的方法
本文实例讲述了Android开发之使用通知栏显示提醒信息的方法。分享给大家供大家参考,具体如下:
用通知栏来提醒
publicvoidnotifyKJ(){
//获得通知管理器,通知是一项系统服务
NotificationManagermanager=(NotificationManager)context.getSystemService(context.NOTIFICATION_SERVICE);
//初始化通知对象p1:通知的图标p2:通知的状态栏显示的提示p3:通知显示的时间
Notificationnotification=newNotification(R.drawable.kjalarm,"提醒",System.currentTimeMillis());
//点击通知后的Intent,此例子点击后还是在当前界面
IntentdescIntent=newIntent(context,com.acp.main.DesktopUI.class);
descIntent.putExtra(DesktopUI.requestCode,DesktopUI.KJ);
PendingIntentintent=PendingIntent.getActivity(context,0,descIntent,0);
//设置通知信息
notification.setLatestEventInfo(context,"提醒","祝您天天快乐",intent);
notification.flags|=Notification.FLAG_AUTO_CANCEL;//当查看后,自动消失
notification.defaults|=Notification.DEFAULT_SOUND;//默认声音提示
//通知
manager.notify(NOTICE_ID,notification);
}
自动跳转到网络设置界面
context.startActivityForResult(newIntent(android.provider.Settings.ACTION_WIRELESS_SETTINGS),0);
希望本文所述对大家Android程序设计有所帮助。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下