当前位置: 移动技术网 > IT编程>移动开发>Android > Android开发之使用通知栏显示提醒信息的方法

Android开发之使用通知栏显示提醒信息的方法

2019年07月24日  | 移动技术网IT编程  | 我要评论

京东商城沙发床,汪嘉年,bemmart

本文实例讲述了android开发之使用通知栏显示提醒信息的方法。分享给大家供大家参考,具体如下:

用通知栏来提醒

public void notifykj() {
 //获得通知管理器,通知是一项系统服务
 notificationmanager manager = (notificationmanager) context.getsystemservice(context.notification_service);
 //初始化通知对象 p1:通知的图标 p2:通知的状态栏显示的提示 p3:通知显示的时间
 notification notification = new notification(r.drawable.kjalarm, "提醒", system.currenttimemillis());
 //点击通知后的intent,此例子点击后还是在当前界面
 intent descintent = new intent(context, com.acp.main.desktopui.class);
 descintent.putextra(desktopui.requestcode,desktopui.kj);
 pendingintent intent = 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(new intent(android.provider.settings.action_wireless_settings),0);

希望本文所述对大家android程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网