温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Notification

发布时间:2020-10-17 00:45:20 来源:网络 阅读:667 作者:风影013 栏目:开发技术

1.android3.0版本以上的用法:

NotificationManager nm = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
       Notification.Builder nb=new Builder(DownLoadService.this);                
       Intent intent=new Intent();
       intent.setAction(Intent.ACTION_CALL);
       intent.setData(Uri.parse("tel:110"));
       PendingIntent pendingIntent=PendingIntent.getActivity(DownLoadService.this, 0, intent, 0);
       nb.setContentTitle("标题");
       nb.setContentText("内容");
       nb.setSmallIcon(R.drawable.alert_dark_frame);
       nb.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.alert_dark_frame));
       nb.setContentIntent(pendingIntent);
       Notification notification=nb.build();
       notification.flags= Notification.FLAG_AUTO_CANCEL;
       nm.notify(0, notification);



2.android任何版本通用用法:

NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
       Notification notification=new Notification(R.drawable.alert_dark_frame,"",System.currentTimeMillis());
       notification.flags= Notification.FLAG_AUTO_CANCEL;
       Intent intent=new Intent();
       intent.setAction(Intent.ACTION_CALL);
       intent.setData(Uri.parse("tel:110"));
       PendingIntent pendingIntent=PendingIntent.getActivity(this, 0, intent, 0);
       notification.setLatestEventInfo(this, "标题", "内容", pendingIntent);
       nm.notify(0, notification);


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI