Android开发工作室发出通知有多行文本显示和关闭触摸

时间:2015-01-08 15:08:53

标签: java android android-intent android-activity android-notifications

.setContentText("Notification content.") // content
// This is my code for the content.

 noti.flags=Notification.FLAG_AUTO_CANCEL; // This is used for closing the notification when touched

Intent intent = new Intent(); // create intent needed by notification

 PendingIntent pIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0); // set intent as pending
                // content, request code, intent, flags

  Notification noti = new Notification.Builder(getApplicationContext()) // build the notification

 .setTicker("ALERT") // ticker title

 .setContentTitle("ALERT") // title

  .setContentText("filler text text text text text text text text text text insert long sentences here")// content title

 .setSmallIcon(R.drawable.ic_launcher) // notification icon

 .setContentIntent (pIntent).getNotification();

 noti.flags=Notification.FLAG_AUTO_CANCEL; // make flag to close notification when touched
                // start notif manager

NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
                // display noficiation
                notificationmanager.notify(0, noti); // first parameter is uniq id,     second param is notif object

Also how do I make it appear in code formatting.

0 个答案:

没有答案