Run AuthService outside of activity context
See original GitHub issueI suddently ran into a weird issue when running AppAuth in my android app in an emulator. Everything works fine on phone, as far as I am concerned but the following exception is thrown inside emulator:
04-25 11:29:52.582 5103-5103/com.myfuturity.futurity W/System.err: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
I tracked the issue down and we are not injecting activity context into the auth state manager and it is apparently needed. We are using KOIN for dependency injection (including context) and all our AppAuth services are injected via Koin.
Is there some workaround that would enable us running AppAuth with application context (that’s the one being injected)? Setting the FLAG_NEW_TASK
to the auth intent does not work, unfortunately.
Thank you for the clarification.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
android - Calling startActivity() from outside of an Activity context
In the onClick method of the OnClickListener , I want to launch a new activity. I get the exception: Calling startActivity() from outside...
Read more >Authenticating service-to-service | Cloud Run Documentation
This code works in any environment - even outside of Google Cloud - where the libraries can obtain authentication credentials, including environments that ......
Read more >AppAuth for Android - OpenID on GitHub
AppAuth for Android uses Gradle as its build system. In order to build the library and app binaries, run ./gradlew assemble . The...
Read more >Hilt by Android - Examples | Medium
Hilt - dependency injection library for Android. Examples from simple to advanced.
Read more >Service Package form – Completing the Context tab
Select the Suppress - Show HTML? check box to cause the system to skip any activity step that calls the Show-HTML method in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any news?
I should probably expose a variant of
getAuthorizationRequestIntent
that allows you to specify the completion and cancelation PendingIntents, so that you can callstartActivity
yourself with the correct context. Alternatively, I could allow the context to be overridden with a parameter passed toperformAuthorizationRequest
.