Conversation
…nt it from crashing
|
People that might come across this same issue, in the meantime I've created a workaround. You can implement your own ContextWrapper where you override the startActivity function, here you can "inject" the flag yourself. Although not the nicest option, this workaround relieves us of maintaining a fork of this repo ourselves with this MR's fix. val wrappedContext: Context = object : ContextWrapper(applicationContext) {
override fun startActivity(intent: Intent?) {
intent?.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
super.startActivity(intent)
}
}Then pass this context to where you need it. |
|
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. |
|
You're absolutely correct, that place looks more justified! |
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).