public void notificationManagerTest(View view){
NotificationManager manager= (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
//下面的频道id一定要设置为State,不然会失效
NotificationCompat.Builder builder=new NotificationCompat.Builder(MainActivity.this, "State");
builder.setContentText("content");//内容
builder.setContentTitle("title");//标题
builder.setSmallIcon(R.drawable.ic_launcher_background);//图标;无论如何都一定要设置,不然会报错
builder.setWhen(System.currentTimeMillis());
manager.notify(1, builder.build());
}
Android--通知栏
猜你喜欢
转载自blog.csdn.net/qq_43616001/article/details/105753344
今日推荐
周排行