I have a twitter application which uses Sign-in with twitter.
It's 'Settings' screen opens an instance of web browser which goes to twitter, asks the user to authenticate my client application, and comes back to the 'Settings' page after redirection from twitter.
Every other thing with twitter and else works fine, except this:
After the authentication, when the control has come back into the 'Settings' activity, the browser instance remains opened.
This causes hindrance in the UI experience whenever the user navigates away from the 'Settings' activity by back button, after logging in.
Pressing the back button takes the user to the web browser instead of taking her to the activity she was at before coming to 'Settings' activity.
Is there any way to get rid of this?
Can I pass any flag with the intent that opens the browser so that the browser knows that it has to close or has not to be there in the view stack of my application?
or any other solution?
Thanks!
Is there any chance you can use a WebView instead of starting the browser with an Intent? That way, you have full control over it and can close it whenever you want.
Related
We recently integrated AppAuth into our application to automate the OAuth2 authorization code flow. When user wants to login, he is first redirected to our auth server, where he proceeds with the login, and then gets redirected back to the application.
We use chrome-custom-tabs to for opening the login page (AppAuth). The problem is that it sometimes gets stuck at a blank screen (chrome tab displays just blank page without the rendered site or redirect). This happens when the user already has a session in the browser so the tab should close automatically and redirect user back to the application (authenticated). It does not behave consistently and we only experience this issue sometimes (~50/50).
I am happy to add some code but don't know where to start (trying to avoid wall of text). Is there a known issue or caveat?
We tried switching contexts as described here but kept experiencing the same issue.
Lead maintainer of AppAuth here. This is most likely happening because the authorization redirect is happening without any user interaction. Chrome enforces a policy that it will only send redirects to your app if the redirect was triggered by a user action, such as submitting a form that redirects or clicking on a link.
If the IDP you are integrating with supports it, you can pass "prompt=consent" as a parameter to force user interaction. Alternatively, you can set up an intermediary page that captures the redirect and displays a "welcome back" message, with a link or button to return to your app.
Another way is to make the user, use the login screen each time.
just add ".setPrompt("login")" to the authRequestBuilder.
so mine will be:
val authRequest = authRequestBuilder
.setPrompt("login")
.build()
There is a verification link in activity. On clicking that link gmail app opens.User can verify through that mail. Now when users opens that activity again, the verification link should stay or go according to the response from api. The issue is after opening the activity,link disappears after fraction of second giving a flicker effect. I wan't that when activity is opened, if verification is true, link doesn't appear
For our product we want to use a feature where the user opens a specific link and our app opens. The user does some stuff and should be redirected back to the same browser.
Is there a way that I can guarantee that the same browser is used? As the user has a session in that specific browser.
so:
webbrowser --> app --> webbrowser
I'm not sure if this is sufficient but if the user behaviour is that he should only interact with your app (and nothing else on the phone) in between the browser visits you should be able to call finish(); on your activity.
From the documentation:
Call this when your activity is done and should be closed.
The ActivityResult is propagated back to whoever launched you via onActivityResult()
\ bob
A user presses on a URL in my app and the URL opens in the mobile browser.
Is it possible that I detect in my app when a user returned from the mobile browser to my app?
Many users will simply read the content of URL and press back to return to my app.
Test case:
user clicks on URL
mobile browser opens the URL
user touches BACK button
app detects that user came back to the app from the mobile browser
If I did not explain this well, please let me know.
I would suggest that you launch the URL with startActivityForResult. Then, when the user returns to your application onActivityResult will be called, and if the RequestCodes align you know it is the web browser.
For more information, take a look at this:
http://developer.android.com/reference/android/app/Activity.html#StartingActivities
We have been working on ways to launch our application from links in Email messages, and we have something that works pretty well. Only URLs with http/https schemes work properly, so we have written a small 'redirector' in our server application that sees we are coming from an Android browser and redirects to a URI with a scheme that our application launches. All of this is working pretty well.
The only bad part is because the browser is launched between clicking the link in the email, and the Application popping up due to the redirect, when the user hits the back button to go back to their email program after using our application, the browser is shown to the user. The browser is left on a blank page, and the user could become confused by this and not know to press the back button again to get back to their email.
When our application is launched from the link the browser will handle the URL and the redirect will cause our application to appear as usual. However, is there a way inside my application to tell Android that my application effectively replaces the browser on the back stack, so that if the back button is pressed, the user goes back to the Email program as if the browser didn't pop up in the first place?
Thanks in advance.
You can skip the entire browser in the middle by using an intent filter. You can register a specific schema to listen for and a given url to launch the application. This will launch your application directly and not put a browser in the middle. The YouTube application uses a method similar I'm sure to open the video directly in the YouTube application. This is a question that might point you in a good direction for implementing this.