Monday, June 14, 2010

[android-developers] SMS notification always displays the first message not the resent message

hi guys,

i have implemented a notification manager which will notify me when
ever i got a new message the notification manager will notify me.
which works fine.

but when ever i expand the notification manager it always displays the
first message not the resent message.

this is the code where I set the notification (SetNotification)


import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import bachelor.markus.R;;

public class SetNotification extends Activity{


public void onCreate(Bundle icicle) {
super.onCreate(icicle);

Bundle extras = getIntent().getExtras();
if (extras != null){
String msg = extras.getString("SMS-MSG");
benachrichtige(msg);
}
}

private static final int NOTIFICATION_ID =12345;

public void benachrichtige(String message){

Context context = getApplicationContext();

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

String notificationText = "Neue Nachricht: "+ message;

Notification notification = new Notification(R.drawable.schloss,
notificationText, System.currentTimeMillis());

Intent activityIntent = new Intent(context,
SmsEmpfaengerGUI.class);
activityIntent.putExtra("SMS-MSG", message);
activityIntent.putExtra("notificationNr", NOTIFICATION_ID);
activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

PendingIntent startIntent = PendingIntent.getActivity(context, 0,
activityIntent, 0);

notification.setLatestEventInfo(context,"Neue Nachricht:", message,
startIntent);
notification.vibrate = new long[] {100,250};

notificationManager.notify(NOTIFICATION_ID, notification);

finish();
}
}


this is where i display the messgage


Bundle bundle = getIntent().getExtras();
String[] receivedSMS= bundle.getStringArray("MSG");
isFromNotify = bundle.getBoolean("From_Noti");
NotificationManager nm = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancelAll();

bundle always contain the first message details. why is that??

regards,
MIke

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment