Android--Service之Notification

来源:互联网 发布:医美网络咨询师好做吗 编辑:程序博客网 时间:2024/06/06 00:36

启动

Notification.Builder builder=new Builder(MainActivity.this);builder.setContentTitle("Test").setContentText("This is test!").setSmallIcon(R.drawable.ic_launcher);PendingIntent pi=PendingIntent.getActivity(getApplicationContext(), 1, new Intent(getApplicationContext(), TestMainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);builder.setContentIntent(pi);builder.setDeleteIntent(pi);NotificationManager n=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);n.notify(1, builder.getNotification());

关闭

NotificationManager n=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);n.cancel(1);
0 0
原创粉丝点击