展会信息港展会大全

android发送状态栏通知 Notification
来源:互联网   发布日期:2015-10-02 21:45:56   浏览:1634次  

导读:android发送状态栏通知 Notificationpublic void sendNotification(Context context, String toast){ Notification notification = new Notification(android.R.drawable.ic_notification_overlay, ......

android发送状态栏通知 Notification

public void sendNotification(Context context, String toast){

Notification notification = new Notification(android.R.drawable.ic_notification_overlay, toast, System.currentTimeMillis()); //创建通知,arg1是通知的图标,arg2是通知的概要,arg3是通知的时间

Intent notificationIntent = new Intent(context, RemoteMp3ListActivity.class);

PendingIntent contentIntent = PendingIntent.getActivity(context, 100, notificationIntent, 0); //点击通知,执行startActivityForResult, arg2是requestCode, arg3是执行的intent

notification.setLatestEventInfo(context, context.getPackageName(), toast, contentIntent); //通知的具体信息. arg2是通知的标题,arg3是通知的内容,arg4是点击后的执行操作

notification.flags = Notification.FLAG_AUTO_CANCEL; //点击后自动消失

NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); //状态栏通知服务

notificationManager.notify( 100, notification);//发送通知, id是为通知设置编号

System.out.println("notification>>>>");

}

赞助本站

人工智能实验室
相关内容
AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港