question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run AuthService outside of activity context

See original GitHub issue

I 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:open
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
halysongoncalvescommented, May 6, 2020

Any news?

5reactions
iainmcgincommented, Apr 26, 2018

I should probably expose a variant of getAuthorizationRequestIntent that allows you to specify the completion and cancelation PendingIntents, so that you can call startActivity yourself with the correct context. Alternatively, I could allow the context to be overridden with a parameter passed to performAuthorizationRequest.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found