Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

[Bug] [Android] Browser.OpenAsync creates new task #1180

Closed
rickclephas opened this issue Mar 18, 2020 · 6 comments
Closed

[Bug] [Android] Browser.OpenAsync creates new task #1180

rickclephas opened this issue Mar 18, 2020 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@rickclephas
Copy link

rickclephas commented Mar 18, 2020

Description

The implementation of Browser.OpenAsync is always starting a new task for the CustomTabs:

var flags = ActivityFlags.ClearTop | ActivityFlags.NewTask;

This means the users will see the CustomTab as a separate app in their recent apps list and won't return to the app when they switch between apps.

Steps to Reproduce

  1. Call Browser.OpenAsync with BrowserLaunchMode.SystemPreferred
  2. When the CustomTab is open switch to another app (without closing the CustomTab)
  3. Now switch back to the CustomTab via the recent apps.
    You will notice that the CustomTab and the test app are both in the list.
    But we'll select the CustomTab since that is where we left off.
  4. Close the CustomTab

Expected Behavior

After closing the CustomTab in step 4 you should return to the test app.

Actual Behavior

After closing the CustomTab in step 4 you return to the home screen.
It looks like the app crashed but it is actually just in the background in another task.

Basic Information

  • Version with issue: 1.5.1
  • Platform Target Frameworks:
    • Android: 10
  • Affected Devices:
    • Google Pixel 3a XL
    • Samsung Galaxy S20+
    • Presumably every other device as well
@rickclephas rickclephas added the bug Something isn't working label Mar 18, 2020
@rickclephas
Copy link
Author

rickclephas commented Mar 18, 2020

The NewTask flag was added in #228 to fix #225 .
Opening the CustomTab (or browser) from within the app should be within the same task to preserve the flow. A new task should only be started if we don't have a running activity.

@rickclephas
Copy link
Author

When this is fixed it would probably also fix #798.

@jamesmontemagno
Copy link
Collaborator

Hmmmmm yes, I agree with you here as I never did this before... Curious why this was put in...

Here is my old code: https://github.com/jguertl/SharePlugin/blob/master/Share/Share.Plugin.Android/ShareImplementation.cs#L41

@jamesmontemagno
Copy link
Collaborator

Although I guess what would happen if you are on a dual screen device and you want it to launch on the second screen... that flag would need to be there....

@rickclephas
Copy link
Author

Although I guess what would happen if you are on a dual screen device and you want it to launch on the second screen... that flag would need to be there....

The flag would indeed be required to launch it on a second screen (or in multi window mode).
Though I think this should be up to the developer of the app.
In most situations I guess you would want it to be the same task (looking at other apps like Twitter, LinkedIn and Github).

Redth added a commit that referenced this issue Mar 25, 2020
jamesmontemagno added a commit that referenced this issue Mar 26, 2020
* Don't launch new task on custom tabs.

* Android Set custom tabs flags for appcontext

* Added BrowserLaunchFlags

This can be a place to expose some platform specific isms.

For now on Android we have a `PrefereAdjacent`  and on iOS a `PreferModal`.

* Added present sheet options, sample

* Use flags in sample

* Cleanup API a little bit and add docs

Co-authored-by: Jonathan Dick <jodick@microsoft.com>
Co-authored-by: Jonathan Dick <jondick@gmail.com>
@jamesmontemagno jamesmontemagno added this to the 1.5.2 milestone Mar 26, 2020
@Redth
Copy link
Member

Redth commented Mar 27, 2020

Fixed in #1183

@Redth Redth closed this as completed Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants