安卓通知栏

2018-01-21  本文已影响0人  水固态中

Intent intent=new Intent(this,NotificationActivity.class);

PendingIntent pi=PendingIntent.getActivity(this,0,intent,0);

NotificationManager manager=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);

Notification notification=new NotificationCompat.Builder(this).

setContentTitle("通知标题").setContentText("内容").

setWhen(System.currentTimeMillis()).

setSmallIcon(R.drawable.ic_launcher).

setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher)).

setContentIntent(pi).

setAutoCancel(true).build();

manager.notify(1,notification);

待续

上一篇 下一篇

猜你喜欢

热点阅读