У меня есть пользовательское уведомление с помощью кнопки. Чтобы установить уведомление и использовать событие OnClick на моей кнопке, я использовал этот код:
//Notification and intent of the notification
Notification notification = new Notification(R.drawable.stat_notify_missed_call,
"Custom Notification", System.currentTimeMillis());
Intent mainIntent = new Intent(getBaseContext(), NotificationActivity.class);
PendingIntent pendingMainIntent = PendingIntent.getActivity(getBaseContext(),
0, mainIntent , 0);
notification.contentIntent = pendingMainIntent;
//Remoteview and intent for my button
RemoteViews notificationView = new RemoteViews(getBaseContext().getPackageName(),
R.layout.remote_view_layout);
Intent activityIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:190"));
PendingIntent pendingLaunchIntent = PendingIntent.getActivity(getBaseContext(), 0,
activityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notificationView.setOnClickPendingIntent(R.id.button1,
pendingLaunchIntent);
notification.contentView = notificationView;
notificationManager.notify(CUSTOM_NOTIFICATION_ID, notification);
С помощью этого кода у меня есть пользовательское уведомление с моим пользовательским макетом... но я не могу нажать кнопку! каждый раз, когда я пытаюсь щелкнуть кнопку, я нажимаю на все уведомление, и поэтому script запускает "mainIntent" вместо "activityIntent".
Я прочитал в Интернете, что этот код не работает на всех терминалах. Я пробовал это на эмуляторе и на HTC Magic, но у меня всегда такая же проблема: я не могу нажать кнопку!
Мой код прав? кто-то может мне помочь?
Спасибо,
Симона