手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >android中创建通知栏Notification代码实例
android中创建通知栏Notification代码实例
摘要://///第一步:获取NotificationManagerNotificationManagernm=(NotificationManag...

///// 第一步:获取NotificationManager NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); ///// 第二步:定义Notification Intent intent = new Intent(this, OtherActivity.class); //PendingIntent是待执行的Intent PendingIntent pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); Notification notification = new Notification.Builder(this) .setContentTitle("title") .setContentText("text") .setSmallIcon(R.drawable.ic_launcher).setContentIntent(pi) .build(); notification.flags = Notification.FLAG_NO_CLEAR; /////第三步:启动通知栏,第一个参数是一个通知的唯一标识 nm.notify(0, notification); //关闭通知 //nm.cancel(0);

【android中创建通知栏Notification代码实例】相关文章:

android WakeLock使用方法代码实例

Android源码中的目录结构详解

android广播接收者实例

Android 混淆代码详解及实例

android中的按两次返回键退出代码

Android中ActionBar以及menu的代码设置样式

android开发之方形圆角listview代码分享

android二级listview列表实现代码

android notification 的总结分析

android 动态控制状态栏显示和隐藏的方法实例

精品推荐
分类导航