0

I'm working with several applications. To log in we uses Oauth2 with customtabs using chrome.

The "mother" application performs a login then send an intent to every application to say "perform login a preload your data in background"

From there each application opens a customtab and close it, then do its other tasks in background.

yes I know, this is ugly, 6 customtabs are being opened and closed, but it is what was asked, no other solution is wanted.

To do that I made an activity without UI.

The activity receive the intent, launch the customtabs, retrieve the authorisation_code, get the tokens, then call a service to preload data and close itself (the invisible activity close itself)

Is that bad?

I did this because it's impossible to add an intent filter to an intent service, and my chrome customtabs send a intent when it's done. so only an activity can grab it.

Thanks.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Heetola
  • 5,791
  • 7
  • 30
  • 45
  • What exactly are the 6 custom chrome tabs for? I don't understand why you need to open 6 of them? – cincy_anddeveloper Dec 17 '18 at 14:54
  • to get the authorisation code you need to perform a login on a url. If the user has already logged in in any application then the webpage will just flash 1 seconds and give you the authorisation code (because there is a cookie in the customtab). each application has to open the custom chrome tabs because it is the only way for an application to get the authorisation code. – Heetola Dec 17 '18 at 15:00
  • Okay, I understand. I think it's a very bad practice to have an invisible UI. There should be something on the screen to indicate what is happening. How can you have an invisible UI with a chrome custom tab? – cincy_anddeveloper Dec 17 '18 at 15:11
  • well by no UI I mean no App UI, the activity does not link to any XML in its onCreate method, the only thing you see is a customtab – Heetola Dec 17 '18 at 15:14
  • Oh okay, I would say that is fine as long as there is a cancel options if the user no longer wants to perform the login. – cincy_anddeveloper Dec 17 '18 at 15:18

1 Answers1

0

I'm guessing you are developing a multiflavored app.

It's perfectly fine to use a deeplink activity to receive the intent to retrieve the code and finish it directly in oncreate

DennisVA
  • 2,068
  • 1
  • 25
  • 35