2

我正在尝试借助带有按钮的远程视图创建自定义通知。我想为此按钮编写 onclick 侦听器,但问题是通知容器正在捕获触摸事件并且未单击按钮。我的问题是有什么方法可以禁用此通知并让按钮被点击。我的代码如下所示:

Notification notification = new Notification(R.drawable.applogo,
        "Apps activated", System.currentTimeMillis());

Intent notificationIntent = new Intent(getBaseContext(), AppsActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(),
0, notificationIntent , 0);
notification.contentIntent = pendingIntent;

//Remoteview and intent for my button
RemoteViews remoteView = new RemoteViews(getBaseContext().getPackageName(),
R.layout.customnotification);

Intent mIntent = getPackageManager().getLaunchIntentForPackage(c.getString(1));//starting some application through package
PendingIntent pintent = PendingIntent.getActivity(this, 0,
                    mIntent, 0);

remoteView.setOnClickPendingIntent(R.id.button1,
pintent);

notification.contentView = remoteView;

notificationManager.notify(CUSTOM_NOTIFICATION_ID, notification);

我正在研究 api 7。谢谢

4

1 回答 1

2

不幸的是,通知布局中的可点击按钮仅适用于 API >= 11 的自定义通知

此外,对于 API >= 16,您可以使用通知操作在通知中提供按钮。

于 2013-08-05T09:37:04.027 回答