Monday, May 30, 2011

[android-developers] Running activity with parameter from status bar notification

Hi all, I'm trying to run my activity from notification with
parameter. The content of activity depends on parameter i send to
activity with intent. It should open my activity when i click on the
information which gives the notification, but the screen does not
change and still remains the same, no matter which activity is
currently running on screen or if I am on my home screen.

Here is my code for notification:

CharSequence text = "You entered \""+name+"\"";
Notification notification = new Notification(R.drawable.icon, text,
System.currentTimeMillis());
Intent intent = new Intent();

// here i say which activity i want to open with click on the
notification
intent.setClassName("com.iwaneez", "com.iwaneez.PlaceSettings");

// here i add my parameter
intent.putExtra("ID", Integer.toString(ID));
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
intent, 0); // creating PendingIntent
notification.setLatestEventInfo(this, "Mannage place\""+name+"\"",
text, contentIntent);

sNM.notify(R.string.notify, notification);


and here is onCreate() method from PlaceSettings activity

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.place_settings);

ID = getIntent().getStringExtra("ID");
loadPlace();
Toast.makeText(this, "ID = "+ID+", Name = "+name,
Toast.LENGTH_LONG).show();
}

but this activity never starts when i click on the notfication...can
you help me please?? i really need this and I'm out of ideas.
Every advice worth.

--
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate