0
我有一個通知,當通過上述通知開啓活動時,應該給我一些參數。Android:通知包未開通
private void notify_newOrders(int count) {
int icon = R.drawable.ic_notification;
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
CharSequence tickerText = infotext;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "Title";
CharSequence contentText = "Infotext";
Intent notificationIntent = new Intent(this, TestActivity.class);
notificationIntent.putExtra("resuming", "123");
notificationIntent.setAction("resuming");
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.flags |= Notification.DEFAULT_ALL;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.number = count;
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(WORKNOTIFICATION_ID, notification);
}
在我的活動我有以下幾點:
@Override
public void onCreate(Bundle savedInstanceState)
{
try{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Bundle extras = getIntent().getExtras();
if(extras != null)
{
Log.d("YAY","got extras");
}
的問題是,我從來沒有得到任何附加功能。我經歷了類似的(解決的)問題,試圖找出他們爲什麼工作,而我的工作並沒有被證明是無用的。幫幫我!
在logcat中我得到這些,不知道他們是否是相關的:
INFO/ActivityManager(59): Starting activity: Intent { act=resuming flg=0x24000000 cmp=com.test.test/.TestActivity bnds=[0,101][320,165] (has extras) }
WARN/ActivityManager(59): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=resuming flg=0x24000000 cmp=com.test.test/.TestActivity bnds=[0,101][320,165] (has extras) }
試過,以及其他在onStart等,沒有任何幫助。 – vampireLady 2012-02-15 17:35:51