{{ message }}
Add FLAG_ACTIVITY_NEW_TASK when context is not an Activity to prevent crashing#765
Closed
SubSide wants to merge 1 commit into
Closed
Add FLAG_ACTIVITY_NEW_TASK when context is not an Activity to prevent crashing#765SubSide wants to merge 1 commit into
SubSide wants to merge 1 commit into
Conversation
…nt it from crashing
jose-a-rodrigues-alb
approved these changes
Dec 2, 2021
Contributor
Author
agologan
pushed a commit
that referenced
this pull request
Dec 7, 2021
Collaborator
|
Approved and merged your changes here: 66d41d2 with a small caveat. While the comment and the explanation correctly explains the caller needs to be an activity or specify a task id or create a new task, the check was done on the context used in the intent creation not the actual caller. This works in this case because the context used is the same but it's not really correct. As such, I moved your code to Let me know if this is what you expected and if you have further concerns. |
agologan
pushed a commit
that referenced
this pull request
Dec 7, 2021
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Checklist
Motivation and Context
In our project we work with clean architecture. Where we access the auth service we don't have access to an Activity context but just the ApplicationContext. When we do perform requests with the Application Context, AppAuth will crash as the intent created needs the FLAG_ACTIVITY_NEW_TASK flag.
Description
The change is minor. If the context is not an Activity we add the FLAG_ACTIVITY_NEW_TASK flag. We try to be as conservative as possible with this by unwrapping the Context if it's a ContextWrapper and checking the root. (As startIntent will be delegated upwards by ContextWrapper to the parent Context as well).