Comments (16)
I decided just to save the connection state in the SharedPreferences (because I do not like saving credentials in SP). Just check the sample project to see how I envision it to work.
from easylogin.
gPlusButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!gPlusNetwork.isConnected()) {
gPlusNetwork.requestLogin(PageLoginFragmentNew.this);
}
boolean testcon = gPlusNetwork.isConnected();
}
});
Problem is when I click on button gPlusNetwork.isConnected() is true but I am not login with ! if is false.
I am trying to remove ! like that
if (gPlusNetwork.isConnected()) {
gPlusNetwork.requestLogin(PageLoginFragmentNew.this);
}
But now I have java.lang.RuntimeException: Already connected, please check isConnected() method
. But I am not logged. I am not seeing popup window for login when I click on button
from easylogin.
@maksim88 This also not working in MainActivity... Any news for this bug?
from easylogin.
Hey,
i'm currently investigating...
GoogleApiClient behaves very weirdly I have to say.
isConnected()
cannot be checked at first, but returns true after onStart()
.
Also there is no easy way to refetch the AccessToken when you are already connected (based on GoogleApiClient)
I'm investigating whether I can silently login and refetch the token that way.
I'll keep you uptodate when I have something new.
For now you can always logout(), and requestLogin() afterwards.
What's your use case exactly?
from easylogin.
In MainActivity I am put 2 button one for Fb and one for G+. When I click on fb button everything works fine. But when I click on G+ button nothing happen. I am run this on Emulator (Android 5, Android 6, Android 7) and on my real device which is Android 5. In all cases same story nothing happen. This is like a button with no events.
from easylogin.
Ok, so the button does not do anything because you are checking for the connection state (isConnected()) and GoogleApiClient returns true in that moment.
I'll upload a new version to jitpack where you can test whether it works better for you. I made some changes to GooglePlusNetwork
gPlusButton in the Activity / Fragment now looks like that:
gPlusButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!gPlusNetwork.isConnected()) {
gPlusNetwork.requestLogin(MainActivity.this);
} else {
gPlusNetwork.setLocalOnCompleteListener(MainActivity.this);
gPlusNetwork.silentSignIn();
}
}
});
in the connected state you can call silentSignIn() and get a token back.
It will be v0.3.1 on jitpack
from easylogin.
Yes, now this works... But when you logged you see button Sign In maybe this replace with button text LogOut...
from easylogin.
When you login with Fb and G+ in same time on Fb button you see LogOut but G+ button stay same text (Sign In). Now you go turn off your device and now you go turn on your device. On facebook you stay logged but on G+ you are not logged.
from easylogin.
Unfortunately the Google SignInButton does not handle its own state like the Facebook button does, that's why it is not possible.
What I saw people do and what I actually liked when I looked at some projects is to call silentSignIn()
in onStart()
of your Activity/ Fragment and if it succeeded then call gPlusButton.setEnabled(false).
Then you will need another mechanism to disconnect (but you need it in all the cases with Google Plus as there is no way to reuse the SignInButton
)
from easylogin.
What you think about that idea.
For example you go login with G+ and now in method onLoginSuccess() you have token, username, email save that in SharedPreferences and now you go turn off your device. Now you turn on your device in fragment in method onCreateView you invoke SharedPreferences data. If you have data you are logged. But now is question if you want to referesh your username or email token is outdatet. Do you have any method to give you new token if you not click on button.
from easylogin.
For example....
For facebook this work if you not logout and turn off/on your device
facebook.isConnected() = true
if(facebook.isConnected()) {
AccessToken token = mEasyLogin.getSocialNetwork(SocialNetwork.Network.FACEBOOK).getAccessToken();
String fbtok = token.getToken();
System.out.println(fbtok);
}
For google
gPlusNetwork.isConnected() = false
after device turn on/off
if(gPlusNetwork.isConnected()){
AccessToken token = mEasyLogin.getSocialNetwork(SocialNetwork.Network.GOOGLE_PLUS).getAccessToken();
String gptok = token.getToken();
System.out.println(gptok);
}
from easylogin.
I'll play around with it on the weekend and think about it
from easylogin.
Ok nice. When you will have new informations share it here 👍
from easylogin.
Do you have any news :)
from easylogin.
I will test now
from easylogin.
@maksim88 Perfect this works fantastic
from easylogin.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easylogin.