【发布时间】:2014-06-24 10:27:19
【问题描述】:
我想在提醒通知中添加一个操作按钮,因此,每当用户单击此类通知时,它都会将用户带到布局文件。..
我知道一般如何添加操作按钮,但是如何在此代码中的通知上添加操作按钮..
需要帮助..提前谢谢..
代码在这里..
public void onReceive(Context context, Intent intent)
{
MediaPlayer mPlayer = MediaPlayer.create(context, R.raw.alert);
mPlayer.start();
mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence from = intent.getStringExtra("Name");
CharSequence message = intent.getStringExtra("Description");
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);
notification = new Notification(R.drawable.alert, "Notification", System.currentTimeMillis());
notification.setLatestEventInfo(context, from, message, contentIntent);
mNotificationManager.notify(Integer.parseInt(intent.getExtras().get("NotifyCount").toString()), notification);
Toast.makeText(context, "New Notification Received", Toast.LENGTH_LONG).show();
}
【问题讨论】:
-
也就是说,你需要通知栏中的按钮?
-
是的,我需要在通知中添加一个按钮
-
吉雅,我想你需要在那里创建自定义按钮
-
你有什么不是@Sparrow的吗?
-
吉亚,你有没有收到我的消息??
标签: android android-intent notifications android-actionbar alert