When I've signed-out from within the Leaderboards by accessing settings, and when I attempt to sign back in, the application crashes. It seems that GameHelper does not register this sign-out.
How does one fix this?
I believe this is a similar issue that was raised on the github repo. Its indicated there that its working as intended.
When you start a GPGS activity, you have to start it with startActivityForResult. If the user clicks on sign-out, the GoogleApiClient is NOT disconnected - it's just in a "signed out" state. The onActivityResult here will return a status RECONNECT_REQUIRED. At this point, the developer should reconnect their client, and life goes on as expected.
Try to modify the RECONNECT_REQUIRED condition block to disconnect, or create a way to handle it specific to your usecase (log-in page?).
Related
Using Spring 4.2.9
Web-Flow: My web-flow has three pages page-1, page-2 and error-Page
Scenario: User clicks on a link in the email, my back-end code consumes the link and user lands on a page-1(the link in the address bar now is different than what the user clicked on), the user does the required stuff on page-1 and clicks continue button and lands on page-2.
What I need when the user is on page-2:
User presses browser back button they should go to error-Page.
The user had copied the link when they were on page-1 and open a new tab and paste the page-1 link, they should land on error-page.
It's a quite common problem. A simple google search gave some possible solutions. Did you tried them? If yes, then update the question with more specifics on the issue. If not, here are a couple of links:
How to Detect Browser Back Button event - Cross Browser
Solution to browser back button click event handling
You can achieve this by configuring a Spring MVC filter (or interceptor). There you can check if the request is GET and it contains the url that you want to block. If true, you can redirect that request to the error or access denied page.
To prevent the user from resetting values when going back with the browser back button you can put a variable in the conversationScope, variables in this scope are not reverted to their previous state when you use the back button. You can this way set a variable when they reach part 2 and check for it when you load part 1, but for this to work part 1 and part 2 need to be in the same flow.
To prevent the users from using a link again, if they are authenticated users you can save a flag in the database that say they have finished the flow and simply look at the database when loading part 1 and throw an exception if the user shouldn't have access. If they are unauthenticated users (like when doing surveys), give each users a token in the url (the token should be random enough that it cannot be brute forced easily) and store it in your database, when part 1 load check that the token is in the database and when your flow is done remove the token from the database.
If you can't do any of this, you can use cookies, just send a cookie to the user when they arrive on part 2, their browser will automatically send it on any new request so if you see it on part 1 you can throw an exception. But users will be able to delete their cookies to circumvent the protection.
Changing page-2 to end-state solved the problem. The solution was mentioned in "The Definitive Guide to Spring Web Flow".
Thank you all for your help.
I have a project setup. https://github.com/Axiom1999/Iron-Banner-Companion/blob/master/app/src/main/java/me/axiom/aapp/ironbannercompanion/
And I have a button which I need to check with the API if the username on the platform exists and if it can get information then start the MainActivity intent.
I do not know how to initially start the connection.
You can use LoginActivity for checking if user already exists. Check this out in onCreate() (i think the best way keep this data in SharedPreferences). If user exists try to login and show LoginActivity with ProgressBar. If user does not exists simply show Login/SignUpActivity
I've been trying to add a custom account to my app so I can manage the authToken to my server better, but I'm confused as to initialise eveything properly.
I've created the Authentication Activity that allows the user to log in, the Authenticator and the service, but I'm not sure how to go about handling the first time the app is opened.
The Authenticator will display the AuthActivty when it doesn't have the users account details, but in the case where the app is opened the first time, the account type doesnt exist in the phone, so I'm unable to call the getAuthToken method in the Authenticator.
Should I check if the account type exists and manually start the LoginAcivity from my MainActivty or am I missing something?
You should actually have a OOBE flow for first time launch where in you can include this.
That means, your launcher should not be main activity. Instead, it could be a spashscreen activity that can decide on whether to go to main activity or take first time launch flow
let me start off by saying happy holidays to everyone!
ok i really just need confirmation and correction if needed.
what im trying to do:
Im using google and facebook "Log-in" feature to sign in for my app to retrieve the data needed like name email etc.
where i Need help:
after signing in i want another activity to be the forefront everytime app opens unless the user signs out then of course, it takes them back to the original main page to sign back in.
now im assuming this takes place in maybe the lifecycle right?
somthing like:
#override
OnResume
{
//if user is signed in cast an Intent to automatically go to another activity?
}
am i on the right track on no? thanks in advance guys
I'm not sure off the top of my head how Google and Facebook's login is implemented... do they have a sample project you're using?
And yep, you're on the right track! Generally speaking you should be able to have a "Main" activity (MainActivity for this example) which checks to see if the login was successful, and if so, kicks you to the activity you want (LoggedInActivity).
This would be in the onCreate() or onResume() method of MainActivity.java
onResume() { // onCreate() should work, too.
if (loggedIn) {
startActivity(new Intent(this, LoggedInActivity.class));
} else {
// send them to login
}
}
If there's not a good way to check if they're logged in, you could save a boolean value or api token using SharedPreferences once the login is successful, and check that value (that'd be the value of loggedIn) every time at launch. You'd obviously need to clear that value any time you logged out.
Recently I've added Google Play Game Services support in my app (added BaseGameActivity and GameHelper), and it sign-in and sign-out workflow worked fine. In my graphics thread I send message to main activity handler, it calls beginUserInitiatedSignIn or signOut. When identification process completes Game Helper calls onSignInFailed or onSignInSucceeded of my activity and I can check isSignedIn (true if onSignInSucceeded was called).
But today I've found that it behaves strange now. Sadly that I did not backup last working version, but the essense code is the same.
If I ask app to sign in it shows google services sign-in dialog (I have 2 accounts on my device). I choose an account, press ok, it returns to my app but neither onSignInSucceeded nor onSignInFailed is called (previously if I canceled this dialog I saw "unknown error" message). When I try to sign in in the second time it launches a rotating circle and waits endlessly. If I tap on screen it aborts waiting and returns to my view.
ALTHOUGH if I close the app and launch it once again, it signs in on launch successfully, call onSignSucceded and stay connected when I check in runtime. It says:
onCreate: creating GamesClient
onStart.
onStart: connecting clients.
Connecting GamesClient.
onConnected: connected! client=1
All clients now connected. Sign-in successful.
All requested clients connected. Sign-in succeeded!
If I sign out and then try to sign in again, it shows accounts dialog and writes:
isGooglePlayServicesAvailable returned 0
beginUserInitiatedSignIn: starting new sign-in flow.
Connecting GamesClient.
onConnectionFailed: result 4
onConnectionFailed: since user initiated sign-in, trying to resolve problem.
resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{41f8a610: android.os.BinderProxy#41f8a5b0}}
result has resolution. Starting it.
When I choose an account it returns to my activity and neither onSignInSucceeded nor onSignInFailed is called. If I check in runtime I see that app is not connected to google services.
When I try to sign in again it shows forever rotating circle and says:
isGooglePlayServicesAvailable returned 0
beginUserInitiatedSignIn: continuing pending sign-in flow.
resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{41f8a610: android.os.BinderProxy#41f8a5b0}}
result has resolution. Starting it.
When I tap the screen, circle is aborted without calls to onSignInSucceeded nor onSignInFailed and so on.
I can't imagine what went wrong. Handler is created on main thread. I have Google example, and it signs in and signs out without any problem, just like my app did. Can somebody tell what can be wrong? Thanks!
It took 2 days to find a silly mistake. When you extend BaseGameActivity make sure you call all its methods in your activity methods (if you override them), for example:
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
....
<our code here>
}
BaseGameActivity calls its aggregated mHelper's methods which do all the magic.