2011-10-23 6 views
1

私は、通知を作成するためのコードがあります。各通知の新しいアクティビティオブジェクトはどのようにすることができますか?

NotificationManager notifyMngr=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); 
    Notification notification=new Notification(mId, "New alert!", System.currentTimeMillis()); 

    Intent alert = new Intent(this, AlertInfoActivity.class); 
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, alert, 0); 

    notification.setLatestEventInfo(this, data.get("name"), data.get("post_date"), contentIntent); 
    notifyMngr.notify((int) System.currentTimeMillis(), notification); 

を私はいくつかの通知を作成する必要があり、各通知はクリックでAlertInfoActivityの新しいオブジェクトを実行する必要があります。しかし、このコードは1つのアクティビティオブジェクトを常に実行します。どのように私の仕事をすることができますか?

+0

ユーザーが1つの通知をクリックしたときに複数のアクティビティを実行したいですか? –

+0

番号。私はいくつかの通知を実行します。 – user975290

答えて

0

起動するアクティビティごとに通知を作成する必要があります。このように:

NotificationManager notifyMngr=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); 

//First Notification 
Notification notification=new Notification(mId, "New alert!", System.currentTimeMillis()); 

Intent alert = new Intent(this, AlertInfoActivity.class); 
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, alert, 0); 

notification.setLatestEventInfo(this, data.get("name"), data.get("post_date"), contentIntent); 
notifyMngr.notify((int) System.currentTimeMillis(), notification); 

//Second Notification 
Notification notification2 = new Notification(mId, "Second Alert!", System.currentTimeMillis()); 

Intent alert2 = new Intent(this, DifferntAcitivty.class); 
PendingIntent contentIntent2 = PendingIntent.getActivity(this, 0, notification2, 0); 

notification2.setLatestEventInfo(this, data.get("name"), data.get("post_date"), contentIntent2); 
notifyMngr.notify((int) System.currentTimeMillis(), notification2); 

//Third Notification 
Notification notification3=new Notification(mId, "Third Alert!", System.currentTimeMillis()); 

Intent alert3 = new Intent(this, ThirdActivity.class); 
PendingIntent contentIntent3 = PendingIntent.getActivity(this, 0, alert3, 0); 

notification3.setLatestEventInfo(this, data.get("name"), data.get("post_date"), contentIntent3); 
notifyMngr.notify((int) System.currentTimeMillis(), notification3); 

//And so on and so forth. 
関連する問題