0
I have the following method to perform a Silentlogin with google +
private void silentLogin() throws MalformedURLException {
OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (pendingResult != null) {
if (pendingResult.isDone()) {
GoogleSignInResult signInResult = pendingResult.get();
profile_pic = new **URL("https://plus.google.com/s2/photos/profile/" + signInResult.getSignInAccount().getId() + "?sz=100");** //url para image
new LoadImage().execute();
} else {
pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
@Override
public void onResult(GoogleSignInResult googleSignInResult) {
GoogleSignInResult signInResult = googleSignInResult;
try {
profile_pic = new URL("https://plus.google.com/s2/photos/profile/" + signInResult.getSignInAccount().getId() + "?sz=100");
} catch (MalformedURLException e) {
e.printStackTrace();
}
new LoadImage().execute();
}
});
}
} else {
progressBar.setVisibility(View.GONE);
startActivity(new Intent(SplashActivity.this, LoginActivity.class));
finish();
}
}
And I have the following class to get the picture
private class Loadimage extends Asynctask {
@Override
protected Void doInBackground(Void... params) {
try {
Bitmap mIcon_val = BitmapFactory.decodeStream(profile_pic.openConnection().getInputStream());
UVSingleton.getInstance().setProfilePicture(mIcon_val);
runOnUiThread(new Runnable() {
@Override
public void run() {
progressBar.setVisibility(View.GONE);
}
});
startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
However I have problem with the url I create because it returns me that the photo does not exist.
What is the right way to get the google profile photo + ?