Whoops...I wasn't done yet:
---------------------------------------------
Option One:
---------------------------------------------
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
processMyIntent(getIntent);
}
@Override
protected void onNewIntent(Intent intent)
{
processMyIntent(intent);
}
private void processMyIntent(Intent intent)
{
intent.doSomething();
}
---------------------------------------------
Option Two:
---------------------------------------------
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
processMyIntent();
}
@Override
protected void onNewIntent(Intent intent)
{
setIntent(intent);
processMyIntent();
}
private void processMyIntent()
{
Intent intent = getIntent();
intent.doSomething;
}
Personally, I'm a fan of Option Two since you might have code
elsewhere that calls getIntent() and it makes sense to me to have
onNewIntent "refresh" the Activity's intent by calling setIntent
(theNewIntent);
On Jan 19, 10:56 am, RNekic <[email protected]> wrote:
> In cases where I've needed to do this, I call a method from both
> onCreate and onNewIntent since, to my knowledge, they don't fire
> together; one or the other fires depending on the situation.
>
> In your Intent processing method, you can either pass in an Intent or
> have it call getIntent(). Note, if your shared method uses getIntent,
> be sure to call setIntent(intent) from within onNewIntent. For
> example:
>
> Option One:
>
> public void onCreate(Bundle savedInstanceState)
> {
> super.onCreate(savedInstanceState);
>
> On Jan 19, 10:37 am, mastix mc <[email protected]> wrote:
>
>
>
> > Hi,
>
> > thanks for the hin, I have now changed the launchmode of my activity
> > to "singleTop":
>
> > and changed the code to look like this:
>
> > // The PendingIntent to launch our activity if the user selects this
> > // notification
> > final Intent notificationIntent = new Intent(ManagerFactory
> > .getMasterActivity(), MailerActivity.class);
> > notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
> > Log.d(TAG, "Set new message to Notification: " + p_message);
> > notificationIntent
> > .putExtra(Constants.NOTIFICATION_EXTRA_KEY, p_message);
> > Log.d(TAG, "Setting requestCodeToFixNotificationBug: "
> > + s_requestCodeToFixNotificationBug);
> > final PendingIntent contentIntent = PendingIntent.getActivity(
> > ManagerFactory.s_service,
> > s_requestCodeToFixNotificationBug++,
> > notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
>
> > notification.setLatestEventInfo(ManagerFactory.s_service,
> > p_tickerText,
> > p_message, contentIntent);
> > return notification;
>
> > Still the same issue! So it did not change anything. :( The app is
> > running in the background... what the heck is going on here? :(
>
> > And @RNekic was right... if the app is not active (running in the
> > background), it does not call onNewIntent() but onCreate(). How could
> > I tell my code to use the old instance instead of creating a new one?
>
> > Sascha
>
> > On Jan 18, 9:15 pm, reyden <[email protected]> wrote:
>
> > > I've had a similar issue with one of my activities that was supposed
> > > to be launched via notifications. After some digging I've solved it by
> > > declaring "singleTop" launch mode for the activity in manifest and by
> > > using FLAG_ACTIVITY_CLEAR_TOP flag on the pending intent for
> > > notification manager...
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en