Bug 26135 - TaskStackBuilder API Improvements
Summary: TaskStackBuilder API Improvements
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 5.1
Hardware: PC Windows
: Normal enhancement
Target Milestone: master
Assignee: dean.ellis
Depends on:
Reported: 2015-01-17 03:27 UTC by Matthew Leibowitz
Modified: 2017-03-21 20:27 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 26135 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Matthew Leibowitz 2015-01-17 03:27:11 UTC
There are some small improvements to the API of the TaskStackBuilder type that can be made:

 - TaskStackBuilder.AddParentStack can be overloaded to accepts a System.Type
 - TaskStackBuilder.GetPendingIntent can be overloaded to accept a PendingIntentFlags

Currently I have to use:

  var intent = new Intent (this, typeof(MainActivity));
  var backStack = TaskStackBuilder.Create (this)
    .AddParentStack (Java.Lang.Class.FromType (typeof(NotificationActivity)))
    .AddNextIntent (intent);
  var pendingIntent = backStack.GetPendingIntent (0, (int)PendingIntentFlags.UpdateCurrent);

It would be better to use:

  var intent = new Intent (this, typeof(MainActivity));
  var backStack = TaskStackBuilder.Create (this)
    .AddParentStack (typeof(NotificationActivity))
    .AddNextIntent (intent);
  var pendingIntent = backStack.GetPendingIntent (0, PendingIntentFlags.UpdateCurrent);
Comment 1 Matthew Leibowitz 2015-01-17 06:41:37 UTC
I notice that this is in the 2.3 API but not in the 4.1
Comment 2 Jonathan Pryor 2015-03-02 12:32:55 UTC
@Dean: Perhaps we should update `generator` to emit a `System.Type` overload for all constructors and methods which accept `Java.Lang.Class`?
Comment 3 dean.ellis 2016-11-08 17:23:32 UTC

would the new "overload" require the Register attribute (on constructors)? I assume not since we don't need to expose this one to the java side of the house. Its been a while since I played with generator...

I also assume we would want to end up with "additional" code like

  public TaskStackBuilder (Type type)  : this (Java.Lang.Class.FromType (type));

  public TaskStackBuilder AddParentStack (Type type) {
     return AddParentStack (Java.Lang.Class.FromType (type));
providing we don't have a System.Type constructor/method already.