Micky
Micky

Reputation: 512

Android - Getting values from a notification

I can't find anything on this on google, nor here? But I am trying to create a notification and retrieve the value of an EditText field that has been set as a custom view for the notification

Is there anyway to retrieve this value? As notification's (as far as I'm aware) can just be set and/or updated.. but there must be some way!

Upvotes: 2

Views: 1335

Answers (2)

Xion
Xion

Reputation: 22770

That's not possible. The actual EditText view inside your notification is not even owned by your process - it's instantiated by the system using the RemoteViews object you are providing. The only way of communicating with it is by sending back predefined intents, for example via setOnClickPendingIntent. You cannot retrieve a content of EditText that way, though.

As a solution I'd recommend to display a dialog or activity with your EditText when user taps the notification, and handle their input there.

Upvotes: 2

Sherif elKhatib
Sherif elKhatib

Reputation: 45942

In your notification Intent

Intent notificationIntent = new Intent(this, FlightActivity.class);
Bundle bundle = new Bundle();
bundle.putString("whatever",YOUR_STRING_VALUE);
notificationIntent.putExtras(bundle);

When the application starts, you can get it using the intent

Is this what you want?

Upvotes: 0

Related Questions