本文整理汇总了Java中com.firebase.ui.auth.IdpResponse类的典型用法代码示例。如果您正苦于以下问题:Java IdpResponse类的具体用法?Java IdpResponse怎么用?Java IdpResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IdpResponse类属于com.firebase.ui.auth包,在下文中一共展示了IdpResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onActivityResult
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
if (resultCode == ResultCodes.OK) {
// Successfully signed in
user = FirebaseAuth.getInstance().getCurrentUser();
email = user.getEmail();
emailEscaped = email.replaceAll("\\.","DOT").replaceFirst("@","AT");
name = user.getDisplayName();
databaseFamilies.addValueEventListener(emailListener);
databaseFamilies.addValueEventListener(managerListener);
databaseFamilies.addValueEventListener(childListener);
//databaseFamilies.addValueEventListener(nameListener);
// String id = databaseFamilies.push().getKey();
} else {
// Sign in failed, check response for error code
// ...
}
}
}
示例2: onActivityResult
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
if(resultCode == Activity.RESULT_OK) {
Toast.makeText(this,"Signed in!", Toast.LENGTH_SHORT).show();
startActivity(new Intent(this,MyLocation.class).putExtra("my_token", response.getIdpToken()));
finish();
return;
} else if(resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(this,"Sign In cancelled.", Toast.LENGTH_SHORT).show();
finish();
}
}
}
示例3: onActivityResult
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case Utility.RC_SIGN_IN:
IdpResponse response = IdpResponse.fromResultIntent(data);
handleSignInResponse(resultCode, response);
break;
case SELECT_PHOTO:
if(resultCode == RESULT_OK){
mPhotoImageView.setImageBitmap(null);
Uri photoUri = data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), photoUri);
mPhotoImageView.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
showSnackBar("Error picking photo");
}
} else {
showSnackBar("Error picking photo");
}
break;
}
}
示例4: handleSignInResponse
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
private void handleSignInResponse(int resultCode, IdpResponse response) {
if (resultCode == ResultCodes.OK) {
updateAuthUI();
return;
} else {
if (response == null) {
showSnackBar("Sign in cancelled");
return;
}
if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
showSnackBar("No internet connection");
return;
}
if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
showSnackBar("Unknown error");
return;
}
}
showSnackBar("Unknown sign_in response");
}
示例5: saveCredentialsOrFinish
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
/**
* If SmartLock is enabled and Google Play Services is available, save the credentials.
* Otherwise, finish the calling Activity with {@link Activity#RESULT_OK}.
* <p>
* Note: saveCredentialsOrFinish cannot be called immediately after getInstance because onCreate
* has not yet been called.
*
* @param firebaseUser Firebase user to save in Credential.
* @param password (optional) password for email credential.
* @param response (optional) an {@link IdpResponse} representing the result of signing in.
*/
public void saveCredentialsOrFinish(FirebaseUser firebaseUser,
@Nullable String password,
@Nullable IdpResponse response) {
mResponse = response;
if (!getFlowParams().enableCredentials) {
finish();
return;
}
mName = firebaseUser.getDisplayName();
mEmail = firebaseUser.getEmail();
mPassword = password;
mProfilePictureUri = firebaseUser.getPhotoUrl() != null ? firebaseUser.getPhotoUrl()
.toString() : null;
mGoogleApiClient = new Builder(mAppContext)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Auth.CREDENTIALS_API)
.enableAutoManage(getActivity(), GoogleApiHelper.getSafeAutoManageId(), this)
.build();
mGoogleApiClient.connect();
}
示例6: onReceiveFirebaseAuthResult
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
private void onReceiveFirebaseAuthResult(int resultCode, Intent data) {
IdpResponse response = IdpResponse.fromResultIntent(data);
// Successfully signed in
if (resultCode == RESULT_OK) {
FirebaseAuthHelper.getIdTokenForCurrentUser(firebaseAuthCallback);
return;
} else {
//Sign in failed
if (response == null) {
// User pressed back button
Log.i(TAG, "BACK button pressed");
return;
}
if (response.getErrorCode() == ErrorCodes.NO_NETWORK || response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
showSnackbar(R.string.dlg_internet_connection_error, Snackbar.LENGTH_INDEFINITE);
return;
}
}
}
示例7: onActivityResult
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// If this is for the sign in activity:
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
if (resultCode == ResultCodes.OK) {
Log.d(TAG, "Login was successful");
// Now that the user is signed in, update currentUser:
currentUser = mAuth.getCurrentUser();
// Transition to the home/settings fragment based on what the user needs to do from here:
navigateBasedOnUser();
} else {
// If there is not a success, try to figure out what went wrong:
if (response == null) Log.e(TAG, "User pressed back button");
else if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
Log.e(TAG, "Network connection error");
Toast.makeText(this, R.string.network_connection_error, Toast.LENGTH_SHORT).show();
} else if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
Log.e(TAG, "Unknown error");
Toast.makeText(this, R.string.unknown_auth_error, Toast.LENGTH_SHORT).show();
showSignIn();
} else Log.e(TAG, "Unknown response");
}
// Debug currentUser again:
Log.d(TAG, "Is the user not signed in? " + Boolean.toString(currentUser == null));
}
}
示例8: onActivityResult
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// RC_SIGN_IN is the request code you passed into startActivityForResult(...) when starting the sign in flow.
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
// Successfully signed in
if (resultCode == ResultCodes.OK) {
SharedPreferences.Editor editor = getSharedPreferences(FIRST_TIME_LOGIN, MODE_PRIVATE).edit();
editor.putBoolean(Constants.IS_FIRST_TIME, true);
editor.apply();
googleLoginButton.setVisibility(View.INVISIBLE);
showWhiteSnackBar(R.string.sign_in_successful);
linearLayout.setVisibility(View.GONE);
Utils.fetchDataFromFirebase(LoginActivity.this);
return;
} else {
if (response == null) {
showWhiteSnackBar(R.string.sign_in_cancelled);
return;
}
if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
showWhiteSnackBar(R.string.no_internet_connection);
return;
}
if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
showWhiteSnackBar(R.string.unknown_error);
return;
}
}
showWhiteSnackBar(R.string.unknown_sign_in_response);
}
}
示例9: onActivityResult
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
// get Idpi Response codes
IdpResponse idpResponse = IdpResponse.fromResultIntent(data);
if (resultCode == RESULT_OK) {
// goto main activity
// FIXME: for testing purposes only
startActivity(new Intent(SplashPageActivity.this, ChooseTypeActivity.class));
} else {
if (idpResponse == null) {
// user pressed back button
showToast("Sign in Cancelled by user.");
return;
} else if (idpResponse.getErrorCode() == ErrorCodes.NO_NETWORK) {
showToast("No internet Connection");
return;
} else if (idpResponse.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
showToast("Some Error Occured!");
return;
}
showToast("Couldn't sign in. Unknown Response, Please try again later.");
}
}
}
示例10: onActivityResult
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// RC_SIGN_IN is the request code you passed into startActivityForResult(...) when starting the sign in flow.
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
// Successfully signed in
if (resultCode == ResultCodes.OK) {
showSnackbar(R.string.signed_in);
return;
} else {
// Sign in failed
if (response == null) {
// User pressed back button
showSnackbar(R.string.sign_in_cancelled);
return;
}
if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
showSnackbar(R.string.no_internet_connection);
return;
}
if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
showSnackbar(R.string.unknown_error);
return;
}
}
showSnackbar(R.string.unknown_sign_in_response);
}
}
示例11: createIntent
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
public static Intent createIntent(
Context context,
IdpResponse idpResponse,
SignedInConfig signedInConfig) {
Intent startIntent = new Intent();
if (idpResponse != null) {
startIntent.putExtra(EXTRA_IDP_RESPONSE, idpResponse);
}
return startIntent.setClass(context, SignedInActivity.class)
.putExtra(EXTRA_SIGNED_IN_CONFIG, signedInConfig);
}
示例12: handleSignInResponse
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
@MainThread
private void handleSignInResponse(int resultCode, Intent data) {
IdpResponse response = IdpResponse.fromResultIntent(data);
// Successfully signed in
if (resultCode == RESULT_OK) {
startSignedInActivity(response);
finish();
return;
} else {
// Sign in failed
if (response == null) {
// User pressed back button
showSnackbar(R.string.sign_in_cancelled);
return;
}
if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
showSnackbar(R.string.no_internet_connection);
return;
}
if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
showSnackbar(R.string.unknown_error);
return;
}
}
showSnackbar(R.string.unknown_sign_in_response);
}
示例13: startSignedInActivity
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
private void startSignedInActivity(IdpResponse response) {
startActivity(
SignedInActivity.createIntent(
this,
response,
new SignedInActivity.SignedInConfig(
getSelectedLogo(),
getSelectedTheme(),
getSelectedProviders(),
getSelectedTosUrl(),
mEnableCredentialSelector.isChecked(),
mEnableHintSelector.isChecked())));
}
示例14: createIntent
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
public static Intent createIntent(
Context context,
FlowParameters flowParams,
IdpResponse response) {
return HelperActivityBase.createBaseIntent(context, WelcomeBackPasswordPrompt.class, flowParams)
.putExtra(ExtraConstants.EXTRA_IDP_RESPONSE, response);
}
示例15: onCreate
import com.firebase.ui.auth.IdpResponse; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fui_welcome_back_password_prompt_layout);
// Show keyboard
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
mSaveSmartLock = getAuthHelper().getSaveSmartLockInstance(this);
mIdpResponse = IdpResponse.fromResultIntent(getIntent());
mEmail = mIdpResponse.getEmail();
mPasswordLayout = findViewById(R.id.password_layout);
mPasswordField = findViewById(R.id.password);
ImeHelper.setImeOnDoneListener(mPasswordField, this);
// Create welcome back text with email bolded.
String bodyText = getString(R.string.fui_welcome_back_password_prompt_body, mEmail);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(bodyText);
int emailStart = bodyText.indexOf(mEmail);
spannableStringBuilder.setSpan(new StyleSpan(Typeface.BOLD),
emailStart,
emailStart + mEmail.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
TextView bodyTextView = findViewById(R.id.welcome_back_password_body);
bodyTextView.setText(spannableStringBuilder);
// Click listeners
findViewById(R.id.button_done).setOnClickListener(this);
findViewById(R.id.trouble_signing_in).setOnClickListener(this);
}