我有 2 个远程视图
- 对于通知内容
- 对于通知自动收报机(我认为这行不通)
我没有包含 2 的代码。一旦我让内容正常工作,我会尝试 2。
下面的代码
Intent intent = new Intent(this, HomeScreen.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.pickupnotification);
RelativeLayout pickupNotificationLayout = (RelativeLayout)this.getLayoutInflater().inflate(R.layout.pickupnotification, null) ;
TextView title = (TextView)pickupNotificationLayout.findViewById(R.id.title) ;
TextView countDown = (TextView)pickupNotificationLayout.findViewById(R.id.countDown) ;
TextView from = (TextView) pickupNotificationLayout.findViewById(R.id.from) ;
TextView to = (TextView) pickupNotificationLayout.findViewById(R.id.to) ;
contentView.apply(this, pickupNotificationLayout);
title.setText("Siddharth" + "2km -> 20km");
countDown.setText("-1:29") ;
from.setText("FROM 2:00pm 14th Jan 2013, Some address") ;
to.setText("TO 4:00pm 14th Jan 2013 Some address") ;
Notification noti = new NotificationCompat.Builder(this).setContent(contentView)
.setSmallIcon(R.drawable.notification_logo)
.setContentIntent(pIntent)
.build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);