【发布时间】:2010-06-21 14:59:00
【问题描述】:
我想知道是否有一种方法可以使用通知栏来执行某些操作(onClick),而无需启动/恢复活动。
例如..假设我提出了一个通知,当用户按下它时,它不会带我去一些活动,而是在我当前的活动/服务中调用一些常规方法
有没有办法实现这样的事情?
例如,当前的通知代码执行标准的 onClick 行为。运行一个活动..如何更改代码以调用某些方法而不是活动?
messagesManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon, message,
System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
new Intent(context, someActivity.class), 0);
notification.setLatestEventInfo(context, "notification", message,
contentIntent);
messagesManager.notify(R.string.noto, notification);
【问题讨论】:
标签: android