Android 在状态栏添加Notification信息图标及提示
代码说明:
这个例子演示Android 在状态栏添加Notification信息图标及提示,相信大家对这个功能已经不陌生了,手机中安装的APP,一般都会在后台运行,时不时会在手机顶部的状态栏中显示应用的图标,滑出状态栏会看到详细的信息,本例子就是模拟实现了此功能: Intent i = new Intent(Sample_6_10.this, NotifiedActivity.class); PendingIntent pi = PendingIntent.getActivity(Sample_6_10.this, 0, i, 0); Notification myNotification = new Notification();//创建一个Notification对象 myNotification.icon=R.drawable.header;//Notification的图标 myNotification.tickerText=getResources().getString(R.string.notification); myNotification.defaults=Notification.DEFAULT_SOUND; myNotification.setLatestEventInfo(Sample_6_10.this, "示例", "点击查看", pi); NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(0, myNotification);//发送Notification
下载说明:请别用迅雷下载,失败请重下,重下不扣分!