我想知道是否有一種方法使用通知欄來執行某些操作(onClick),而無需啓動/恢復活動。自定義通知
例如..比方說,我養notifcation,並在其上的用戶按,然後而不是帶我去一些活動,它調用了一些普通的方法在我的當前活動/服務
有什麼實施這樣的事情的方式?
例如,當前通知代碼在onClick上表現出非標準行爲。運行一個活動..如何將channge的代碼,以調用一些方法,而不是一個活動?
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);
getService或getBroadcast將如何幫助我調用常規方法?你能告訴我一些這樣的未決意圖嗎? – Moshik 2010-06-21 07:24:08
在通過點擊通知啓動的'BroadcastReceiver'或'Service'(而不是'Activity')中,這是您可以「調用某種方法」的地方。 – 2010-06-21 07:57:39
是的,但我將如何調用一個方法,(通過通知欄)在引發該通知的同一服務中?是他們任何方法,我可以在通知管理器調用getService時從服務中覆蓋(並從那裏我可以導航到我的目標方法) – Moshik 2010-06-21 08:39:15