本文整理匯總了Java中com.google.android.gms.tasks.OnFailureListener類的典型用法代碼示例。如果您正苦於以下問題:Java OnFailureListener類的具體用法?Java OnFailureListener怎麽用?Java OnFailureListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OnFailureListener類屬於com.google.android.gms.tasks包,在下文中一共展示了OnFailureListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fetchconfig
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
private void fetchconfig() {
long cacheExpiration = 3600;
if(mFirebaseRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()){
cacheExpiration=0;
}
mFirebaseRemoteConfig.fetch(cacheExpiration)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
mFirebaseRemoteConfig.activateFetched();
applyRetrievelengthLimit();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG,"Error Fetching config", e);
applyRetrievelengthLimit();
}
});
}
示例2: fetchConfig
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
public void fetchConfig() {
long cacheExpiration = 3600; // 1 hour in seconds
// If developer mode is enabled reduce cacheExpiration to 0 so that each fetch goes to the
// server. This should not be used in release builds.
if (mFirebaseRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
cacheExpiration = 0;
}
mFirebaseRemoteConfig.fetch(cacheExpiration)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
// Make the fetched config available via FirebaseRemoteConfig get<type> calls.
mFirebaseRemoteConfig.activateFetched();
applyRetrievedLengthLimit();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// There has been an error fetching the config
Log.w(TAG, "Error fetching config", e);
applyRetrievedLengthLimit();
}
});
}
示例3: onActivityResult
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == GALLERY_INTENT && resultCode == RESULT_OK){
showProgressDialog();
Uri uri = data.getData();
StorageReference filePath = mStorage.child("fotos").child(uri.getLastPathSegment());
filePath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
hideProgressDialog();
Uri downloadUri = taskSnapshot.getDownloadUrl();
imageUrl = downloadUri;
Picasso.with(NewPostActivity.this).load(downloadUri).fit().centerCrop().into(mCriminalPicture);
Toast.makeText(NewPostActivity.this, R.string.upload__success, Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
hideProgressDialog();
Toast.makeText(NewPostActivity.this, R.string.upload_failure, Toast.LENGTH_SHORT).show();
}
});
}
}
示例4: achievement_show_list
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
public void achievement_show_list() {
connect();
if (isConnected()) {
mAchievementsClient.getAchievementsIntent()
.addOnSuccessListener(new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
activity.startActivityForResult(intent, REQUEST_ACHIEVEMENTS);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "Showing::Loaderboard::Failed:: " + e.toString());
}
});
} else { Log.i(TAG, "PlayGameServices: Google calling connect"); }
}
示例5: leaderboard_show
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
public void leaderboard_show(final String l_id) {
connect();
if (isConnected()) {
mLeaderboardsClient.getLeaderboardIntent(l_id)
.addOnSuccessListener(new OnSuccessListener<Intent>() {
@Override
public void onSuccess (Intent intent) {
Log.d(TAG, "Showing::Loaderboard::" + l_id);
activity.startActivityForResult(intent, REQUEST_LEADERBOARD);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "Showing::Loaderboard::Failed:: " + e.toString());
}
});
} else { Log.i(TAG, "PlayGameServices: Google not connected calling connect"); }
}
示例6: leaderboard_show_list
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
public void leaderboard_show_list() {
connect();
if (isConnected()) {
mLeaderboardsClient.getAllLeaderboardsIntent()
.addOnSuccessListener(new OnSuccessListener<Intent>() {
@Override
public void onSuccess (Intent intent) {
Log.d(TAG, "Showing::Loaderboard::List");
activity.startActivityForResult(intent, REQUEST_LEADERBOARD);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "Showing::Loaderboard::Failed:: " + e.toString());
}
});
} else { Log.i(TAG, "PlayGameServices: Google not connected calling connect"); }
}
示例7: uploadImageToFirebase
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
private void uploadImageToFirebase(Uri file) {
imageFilename = UUID.randomUUID().toString().replaceAll("-", "") + ".jpg";
currentUser = mAuth.getCurrentUser();
StorageReference postedImagesRef = mStorageRef.child(currentUser.getUid()).child(imageFilename);
postedImagesRef.putFile(file)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// Get a URL to the uploaded content
imageDownloadUrl = taskSnapshot.getDownloadUrl().toString();
Log.d(TAG, "success: Image upload");
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Log.d(TAG, "failed: Image upload");
}
});
}
示例8: getAvailableFileName
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
private void getAvailableFileName(final FetchDataCallback callback) {
Task<Uri> searchTask = mStorage.child(mResources.getString(R.string.storage_template, mFileIndex)).getDownloadUrl();
searchTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// If failed, that means the file does not exist, so we call callback
callback.onDataFetched();
}
}).addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
// if successful, that means a file was found, so increment index
mFileIndex++;
// Recursive call until we fail to find a file
getAvailableFileName(callback);
}
});
}
示例9: firebaseAuthWithGoogle
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
Log.d(TAG, "firebaseAuthWithGooogle:" + acct.getId());
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
showProgressDialog(getString(R.string.profile_progress_message));
mAuth.signInWithCredential(credential)
.addOnSuccessListener(this, new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult result) {
handleFirebaseAuthResult(result);
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
FirebaseCrash.logcat(Log.ERROR, TAG, "auth:onFailure:" + e.getMessage());
handleFirebaseAuthResult(null);
}
});
}
示例10: onClick
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.explore_button:
mAuth.signInAnonymously().addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
Intent feedsIntent = new Intent(WelcomeActivity.this, FeedsActivity.class);
startActivity(feedsIntent);
}
}).addOnFailureListener( new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(WelcomeActivity.this, "Unable to sign in anonymously.",
Toast.LENGTH_SHORT).show();
Log.e(TAG, e.getMessage());
}
});
break;
case R.id.sign_in_button:
Intent signInIntent = new Intent(this, ProfileActivity.class);
startActivity(signInIntent);
break;
}
}
示例11: fetchConfig
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
public void fetchConfig(){
long catchExpiration = 3600;
if (mFirebaseRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()){
catchExpiration = 0;
}
mFirebaseRemoteConfig.fetch(catchExpiration)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
mFirebaseRemoteConfig.activateFetched();
applyRetrievedLengthLimit();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "Error fetching config", e);
applyRetrievedLengthLimit();
}
});
}
示例12: onSmokeTestClicked
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
private void onSmokeTestClicked() {
FirebaseAuth.getInstance()
.signInAnonymously()
.addOnSuccessListener(this, new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
Log.d(TAG, "auth:onSuccess");
// Run snippets
DocSnippets docSnippets = new DocSnippets(mFirestore);
docSnippets.runAll();
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "auth:onFailure", e);
}
});
}
示例13: addAdaLovelace
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
private void addAdaLovelace() {
// [START add_ada_lovelace]
// Create a new user with a first and last name
Map<String, Object> user = new HashMap<>();
user.put("first", "Ada");
user.put("last", "Lovelace");
user.put("born", 1815);
// Add a new document with a generated ID
db.collection("users")
.add(user)
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
@Override
public void onSuccess(DocumentReference documentReference) {
Log.d(TAG, "DocumentSnapshot added with ID: " + documentReference.getId());
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "Error adding document", e);
}
});
// [END add_ada_lovelace]
}
示例14: setValue
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
/**
* Set the given value on the specified {@link DatabaseReference}.
*
* @param ref reference represents a particular location in your database.
* @param value value to update.
* @return a {@link Completable} which is complete when the set value call finish successfully.
*/
@NonNull
public static Completable setValue(@NonNull final DatabaseReference ref,
final Object value) {
return Completable.create(new CompletableOnSubscribe() {
@Override
public void subscribe(@io.reactivex.annotations.NonNull final CompletableEmitter e) throws Exception {
ref.setValue(value).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override public void onSuccess(Void aVoid) {
e.onComplete();
}
}).addOnFailureListener(new OnFailureListener() {
@Override public void onFailure(@NonNull Exception exception) {
e.onError(exception);
}
});
}
});
}
示例15: insertAuthor
import com.google.android.gms.tasks.OnFailureListener; //導入依賴的package包/類
public void insertAuthor(Author author) {
mAuthorReference.child(author.getKey()).setValue(author).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(LOG_TAG, e.getLocalizedMessage());
}
}).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
insertAuthorCount++;
if(insertAuthorCount== ITERATIONS){
logEvent("Insert "+ ITERATIONS +" Authors", initialTimeAuthorCount, new Date());
}
}
});
mAuthorReference.push();
}