本文整理汇总了Java中com.google.firebase.FirebaseException类的典型用法代码示例。如果您正苦于以下问题:Java FirebaseException类的具体用法?Java FirebaseException怎么用?Java FirebaseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FirebaseException类属于com.google.firebase包,在下文中一共展示了FirebaseException类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: phoneNumberVerificationCB
import com.google.firebase.FirebaseException; //导入依赖的package包/类
private void phoneNumberVerificationCB() {
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
Log.d(TAG, "onVerificationCompleted:" + credential);
credent = credential;
}
@Override
public void onVerificationFailed(FirebaseException e) {
Log.w(TAG, "onVerificationFailed", e);
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// ...
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// ...
}
}
};
}
开发者ID:kcj8855,项目名称:Ae4Team,代码行数:24,代码来源:ChangePhoneNumberActivity.java
示例2: observe
import com.google.firebase.FirebaseException; //导入依赖的package包/类
private Observable<DataSnapshot> observe(final Query ref) {
return Observable.create(emitter -> {
final ValueEventListener listener =
ref.addValueEventListener(new ValueEventListener() {
@Override public void onDataChange(DataSnapshot dataSnapshot) {
emitter.onNext(dataSnapshot);
}
@Override public void onCancelled(DatabaseError databaseError) {
emitter.onError(new FirebaseException(databaseError.getMessage()));
}
});
emitter.setCancellable(() -> ref.removeEventListener(listener));
});
}
开发者ID:riteshakya037,项目名称:Wallpapers-Android-Clean-Architecture,代码行数:17,代码来源:Comments.java
示例3: createIfNotExists
import com.google.firebase.FirebaseException; //导入依赖的package包/类
protected <T extends Entity, R> Observable<R> createIfNotExists(DatabaseReference databaseReference, T value, R successResponse) {
return Observable.create(new Observable.OnSubscribe<R>() {
@Override
public void call(Subscriber<? super R> subscriber) {
databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.getValue() == null) {
postQuery(databaseReference, value, false, successResponse)
.subscribe(subscriber);
} else {
subscriber.onNext(successResponse);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
subscriber.onError(new FirebaseException(databaseError.getMessage()));
}
});
}
});
}
开发者ID:ihorvitruk,项目名称:buddysearch,代码行数:24,代码来源:FirebaseEntityStore.java
示例4: getQuery
import com.google.firebase.FirebaseException; //导入依赖的package包/类
private <T> Observable<T> getQuery(Query query, Action2<Subscriber<? super T>, DataSnapshot> onNextAction, boolean subscribeForSingleEvent) {
return Observable.create(subscriber -> {
ValueEventListener eventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
onNextAction.call(subscriber, dataSnapshot);
}
@Override
public void onCancelled(DatabaseError databaseError) {
subscriber.onError(new FirebaseException(databaseError.getMessage()));
}
};
if (subscribeForSingleEvent) {
query.addListenerForSingleValueEvent(eventListener);
} else {
query.addValueEventListener(eventListener);
}
subscriber.add(Subscriptions.create(() -> query.removeEventListener(eventListener)));
});
}
开发者ID:ihorvitruk,项目名称:buddysearch,代码行数:23,代码来源:FirebaseEntityStore.java
示例5: postQuery
import com.google.firebase.FirebaseException; //导入依赖的package包/类
private <T extends Entity, R> Observable<R> postQuery(DatabaseReference databaseReference, T value, boolean newChild, R successResponse) {
return Observable.create(new Observable.OnSubscribe<R>() {
@Override
public void call(Subscriber<? super R> subscriber) {
DatabaseReference reference = databaseReference;
if (newChild) {
if (value.getId() == null) {
reference = databaseReference.push();
value.setId(reference.getKey());
} else {
reference = databaseReference.child(value.getId());
}
}
reference.setValue(value, (databaseError, databaseReference1) -> {
if (databaseError == null) {
subscriber.onNext(successResponse);
} else {
subscriber.onError(new FirebaseException(databaseError.getMessage()));
}
});
}
});
}
开发者ID:ihorvitruk,项目名称:buddysearch,代码行数:25,代码来源:FirebaseEntityStore.java
示例6: handelError
import com.google.firebase.FirebaseException; //导入依赖的package包/类
public static String handelError(Throwable error) {
if (isRelatedToNetwork(error)) {
return App.getGlobalContext().getString(R.string.error_network_no_internet_connection);
} else if (error instanceof HttpException) {
try {
HttpException retroError = (HttpException) error;
ApiError errorObj = new Gson().fromJson(retroError.response().errorBody().charStream(), ApiError.class);
return ErrorFactory.getErrorMessage(errorObj.getCode());
} catch (Throwable e) {
e.printStackTrace();
}
} else if (error instanceof FirebaseException) {
return error.getMessage();
}
return ErrorFactory.getErrorMessage(ErrorFactory.GENERAL_DEFAULT_ERROR);
}
开发者ID:scott7462,项目名称:Udacity-Capstone-Project,代码行数:18,代码来源:ApiErrorRest.java
示例7: sendComment
import com.google.firebase.FirebaseException; //导入依赖的package包/类
@Override public Observable sendComment(final String photoId, final String message) {
return Observable.create(new Observable.OnSubscribe<Boolean>() {
@Override
public void call(final Subscriber<? super Boolean> subscriber) {
databaseReference.child(DatabaseNames.TABLE_COMMENTS)
.child(String.valueOf(photoId))
.push()
.setValue(new PhotoComment(Calendar.getInstance().getTime(), message))
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override public void onComplete(@NonNull Task<Void> task) {
subscriber.onNext(task.isSuccessful());
subscriber.onCompleted();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override public void onFailure(@NonNull Exception e) {
subscriber.onError(new FirebaseException(e.getMessage()));
}
});
}
});
}
开发者ID:lolevsky,项目名称:Android-Clean-Architecture,代码行数:23,代码来源:Comments.java
示例8: observe
import com.google.firebase.FirebaseException; //导入依赖的package包/类
private Observable<DataSnapshot> observe(final Query ref) {
return Observable.create(new Observable.OnSubscribe<DataSnapshot>() {
@Override
public void call(final Subscriber<? super DataSnapshot> subscriber) {
final ValueEventListener listener = ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
subscriber.onNext(dataSnapshot);
}
@Override public void onCancelled(DatabaseError databaseError) {
subscriber.onError(new FirebaseException(databaseError.getMessage()));
}
});
// When the subscription is cancelled, remove the listener
subscriber.add(Subscriptions.create(new Action0() {
@Override
public void call() {
ref.removeEventListener(listener);
}
}));
}
});
}
开发者ID:lolevsky,项目名称:Android-Clean-Architecture,代码行数:26,代码来源:Comments.java
示例9: verifyPhoneNumber
import com.google.firebase.FirebaseException; //导入依赖的package包/类
private void verifyPhoneNumber(final String phoneNumber, final CallbackContext callbackContext) {
cordova.getThreadPool().execute(new Runnable() {
@Override
public void run() {
phoneAuthProvider.verifyPhoneNumber(phoneNumber, 0, MILLISECONDS, cordova.getActivity(),
new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user == null) {
firebaseAuth.signInWithCredential(credential);
} else {
user.updatePhoneNumber(credential);
}
callbackContext.success("");
}
@Override
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
callbackContext.success(verificationId);
}
@Override
public void onVerificationFailed(FirebaseException e) {
callbackContext.error(e.getMessage());
}
}
);
}
});
}
开发者ID:chemerisuk,项目名称:cordova-plugin-firebase-authentication,代码行数:33,代码来源:FirebaseAuthenticationPlugin.java
示例10: sendComment
import com.google.firebase.FirebaseException; //导入依赖的package包/类
@Override public Observable sendComment(final String photoId, final CommentsModel message) {
return Observable.create((ObservableOnSubscribe<Boolean>) emitter -> databaseReference.child(DatabaseNames.TABLE_COMMENTS)
.child(String.valueOf(photoId))
.push()
.setValue(message)
.addOnCompleteListener(task -> {
emitter.onNext(task.isSuccessful());
emitter.onComplete();
})
.addOnFailureListener(e -> {
e.printStackTrace();
emitter.onError(new FirebaseException(e.getMessage()));
}));
}
开发者ID:riteshakya037,项目名称:Wallpapers-Android-Clean-Architecture,代码行数:15,代码来源:Comments.java
示例11: verifyPhoneNumber
import com.google.firebase.FirebaseException; //导入依赖的package包/类
private void verifyPhoneNumber(final String phoneNumber, final long timeout, final CallbackContext callbackContext) {
cordova.getThreadPool().execute(new Runnable() {
@Override
public void run() {
phoneAuthProvider.verifyPhoneNumber(phoneNumber, timeout, MILLISECONDS, cordova.getActivity(),
new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user == null) {
firebaseAuth.signInWithCredential(credential);
} else {
user.updatePhoneNumber(credential);
}
}
@Override
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
callbackContext.success(verificationId);
}
@Override
public void onVerificationFailed(FirebaseException e) {
callbackContext.error(e.getMessage());
}
}
);
}
});
}
开发者ID:kanodeveloper,项目名称:cordova-plugin-firebase-performance-ka,代码行数:31,代码来源:FirebaseAuthenticationPlugin.java
示例12: signInGoogle
import com.google.firebase.FirebaseException; //导入依赖的package包/类
@Override
public void signInGoogle(GoogleSignInAccount acct, Subscriber<String> subscriber, CreateUser createUser) {
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
auth.signInWithCredential(credential)
.addOnCompleteListener(task -> {
if (!subscriber.isUnsubscribed()) {
if (task.isSuccessful()) {
saveUser(task.getResult().getUser(), subscriber, createUser);
} else {
subscriber.onError(new FirebaseException(task.getException().getMessage()));
}
}
});
}
开发者ID:ihorvitruk,项目名称:buddysearch,代码行数:15,代码来源:AuthManagerImpl.java
示例13: deleteQuery
import com.google.firebase.FirebaseException; //导入依赖的package包/类
private <R> Observable<R> deleteQuery(DatabaseReference databaseReference, R successResponse) {
return Observable.create(new Observable.OnSubscribe<R>() {
@Override
public void call(Subscriber<? super R> subscriber) {
databaseReference.removeValue((databaseError, databaseReference1) -> {
if (databaseError == null) {
subscriber.onNext(successResponse);
} else {
subscriber.onError(new FirebaseException(databaseError.getMessage()));
}
});
}
});
}
开发者ID:ihorvitruk,项目名称:buddysearch,代码行数:15,代码来源:FirebaseEntityStore.java
示例14: observe
import com.google.firebase.FirebaseException; //导入依赖的package包/类
public static Observable<DataSnapshot> observe(final Query ref) {
return Observable.create(new Observable.OnSubscribe<DataSnapshot>() {
@Override
public void call(final Subscriber<? super DataSnapshot> subscriber) {
final ValueEventListener listener = ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
subscriber.onNext(dataSnapshot);
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Turn the FirebaseError into a throwable to conform to the API
subscriber.onError(new FirebaseException(databaseError.getMessage()));
}
});
// When the subscription is cancelled, remove the listener
subscriber.add(Subscriptions.create(new Action0() {
@Override
public void call() {
ref.removeEventListener(listener);
}
}));
}
});
}
开发者ID:chungtruong,项目名称:AndroidDataBinding,代码行数:30,代码来源:RxFirebase.java
示例15: onVerificationFailed
import com.google.firebase.FirebaseException; //导入依赖的package包/类
private void onVerificationFailed(@NonNull FirebaseException ex) {
dismissLoadingDialog();
if (ex instanceof FirebaseAuthException) {
FirebaseAuthError error = FirebaseAuthError.fromException((FirebaseAuthException) ex);
switch (error) {
case ERROR_INVALID_PHONE_NUMBER:
VerifyPhoneNumberFragment verifyPhoneNumberFragment = (VerifyPhoneNumberFragment)
getSupportFragmentManager().findFragmentByTag(VerifyPhoneNumberFragment.TAG);
if (verifyPhoneNumberFragment != null) {
verifyPhoneNumberFragment.showError(
getString(R.string.fui_invalid_phone_number));
}
break;
case ERROR_TOO_MANY_REQUESTS:
showAlertDialog(getString(R.string.fui_error_too_many_attempts), null);
break;
case ERROR_QUOTA_EXCEEDED:
showAlertDialog(getString(R.string.fui_error_quota_exceeded), null);
break;
default:
Log.w(PHONE_VERIFICATION_LOG_TAG, error.getDescription(), ex);
showAlertDialog(error.getDescription(), null);
}
} else {
Log.w(PHONE_VERIFICATION_LOG_TAG, ex.getLocalizedMessage());
showAlertDialog(ex.getLocalizedMessage(), null);
}
}
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:32,代码来源:PhoneActivity.java
示例16: sendCode
import com.google.firebase.FirebaseException; //导入依赖的package包/类
private void sendCode(String phoneNumber, boolean forceResend) {
mPhoneNumber = phoneNumber;
mVerificationState = VerificationState.VERIFICATION_STARTED;
getAuthHelper().getPhoneAuthProvider().verifyPhoneNumber(
phoneNumber,
AUTO_RETRIEVAL_TIMEOUT_MILLIS,
TimeUnit.MILLISECONDS,
this,
new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential) {
if (!mIsDestroyed) {
PhoneActivity.this.onVerificationSuccess(phoneAuthCredential);
}
}
@Override
public void onVerificationFailed(FirebaseException ex) {
if (!mIsDestroyed) {
PhoneActivity.this.onVerificationFailed(ex);
}
}
@Override
public void onCodeSent(@NonNull String verificationId,
@NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken) {
mVerificationId = verificationId;
mForceResendingToken = forceResendingToken;
if (!mIsDestroyed) {
PhoneActivity.this.onCodeSent();
}
}
},
forceResend ? mForceResendingToken : null);
}
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:37,代码来源:PhoneActivity.java
示例17: onCreate
import com.google.firebase.FirebaseException; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_otp);
sentNumber="INVALID";
//Check for the OTP
mCallbacks=new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
sentNumber=phoneAuthCredential.getSmsCode();
Toasty.success(OTP.this, "Verification Success", Toast.LENGTH_SHORT).show();
moveToNextActivity();
}
@Override
public void onVerificationFailed(FirebaseException e) {
Toasty.error(OTP.this, "Invalid OTP", Toast.LENGTH_SHORT).show();
}
@Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
// Log.d(TAG, "onCodeSent:" + verificationId);
Toasty.info(OTP.this, "OTP has been send to your number", Toast.LENGTH_SHORT).show();
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
mResendToken = token;
}
};
//Phone Auth Parameters
PhoneAuthProvider.getInstance().verifyPhoneNumber(
LocalDB.getPhoneNumber(),
60,
java.util.concurrent.TimeUnit.SECONDS,
OTP.this,
mCallbacks);
if(!isNetworkAvailable())
{
Toasty.warning(OTP.this,"Please Check Your Internet Connection and Try Again", Toast.LENGTH_SHORT).show();
}
}
开发者ID:Nihal369,项目名称:Amaro,代码行数:52,代码来源:OTP.java
示例18: verifyPhoneNumber
import com.google.firebase.FirebaseException; //导入依赖的package包/类
private void verifyPhoneNumber(String phoneNumber){
if (!isValid){
Toast.makeText(this, "Invalid Phone number!", Toast.LENGTH_SHORT).show();
return;
}
hud.show();
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
// This callback will be invoked in two situations:
// 1 - Instant verification. In some cases the phone number can be instantly
// verified without needing to send or enter a verification code.
// 2 - Auto-retrieval. On some devices Google Play services can automatically
// detect the incoming verification SMS and perform verification without
// user action.
Log.d(TAG, "onVerificationCompleted:" + credential);
hud.dismiss();
signInWithPhoneAuthCredential(credential);
}
@Override
public void onVerificationFailed(FirebaseException e) {
// This callback is invoked in an invalid request for verification is made,
// for instance if the the phone number format is not valid.
Toast.makeText(RegisterPhoneActivity.this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
Toast.makeText(RegisterPhoneActivity.this, "Invalid mobile number", Toast.LENGTH_SHORT).show();
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
Toast.makeText(RegisterPhoneActivity.this, "The SMS quota for the project has been exceeded", Toast.LENGTH_SHORT).show();
}
// Show a message and update the UI
hud.dismiss();
}
@Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
// The SMS verification code has been sent to the provided phone number, we
// now need to ask the user to enter the code and then construct a credential
// by combining the code with a verification ID.
Log.d(TAG, "onCodeSent:" + verificationId);
// Save verification ID and resending token so we can use them later
phoneVerficationID = verificationId;
resendToken = token;
Toast.makeText(RegisterPhoneActivity.this, getString(R.string.register_verify_sent), Toast.LENGTH_SHORT).show();
hud.dismiss();
startResendTimer();
}
};
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber,
60,
TimeUnit.SECONDS,
this,
mCallbacks);
}
开发者ID:AppHero2,项目名称:Raffler-Android,代码行数:71,代码来源:RegisterPhoneActivity.java
示例19: signUp
import com.google.firebase.FirebaseException; //导入依赖的package包/类
/**
* Method to handle sign up process
*
* @param v
*/
private void signUp(final View v) {
if (phoneNoEditext.length() == 0) { // if phone no field empty
Snackbar.make(v, R.string.insertphoneno, Snackbar.LENGTH_LONG)
.show();
return;
}
String phoneNumber = phoneNoEditext.getText().toString();
// Copy code from google
// https://firebase.google.com/docs/auth/android/phone-auth
// code to verify phone number.
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
signIn(v, phoneAuthCredential);
}
@Override
public void onVerificationFailed(FirebaseException e) {
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// [START_EXCLUDE]
phoneNoEditext.setError("Invalid phone number.");
// [END_EXCLUDE]
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// [START_EXCLUDE]
Snackbar.make(findViewById(android.R.id.content), "Quota exceeded.",
Snackbar.LENGTH_SHORT).show();
// [END_EXCLUDE]
}
}
@Override
public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s, forceResendingToken);
verificationId = s;
showVerificationLayout();
}
});
}
开发者ID:shiburagi,项目名称:SignUpPhone,代码行数:57,代码来源:LoginActivity.java
注:本文中的com.google.firebase.FirebaseException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论