当前位置: 首页>>代码示例>>Java>>正文


Java OnFailureListener类代码示例

本文整理汇总了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();
        }
    });
}
 
开发者ID:de-crypto,项目名称:ChatShala,代码行数:22,代码来源:MainActivity.java

示例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();
                }
            });
}
 
开发者ID:firebase,项目名称:friendlychat-android,代码行数:26,代码来源:MainActivity.java

示例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();
            }
        });
    }
}
 
开发者ID:braulio94,项目名称:Quadro,代码行数:27,代码来源:NewPostActivity.java

示例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"); }
}
 
开发者ID:FrogSquare,项目名称:GodotGoogleService,代码行数:21,代码来源:PlayService.java

示例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"); }
}
 
开发者ID:FrogSquare,项目名称:GodotGoogleService,代码行数:22,代码来源:PlayService.java

示例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"); }
}
 
开发者ID:FrogSquare,项目名称:GodotGoogleService,代码行数:22,代码来源:PlayService.java

示例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");
                }
            });
    }
 
开发者ID:sindhu732,项目名称:instagram_clone,代码行数:23,代码来源:UploadActivity.java

示例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);
        }
    });
}
 
开发者ID:AviralGarg1993,项目名称:VR-One,代码行数:19,代码来源:MainActivity.java

示例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);
                }
            });
}
 
开发者ID:firebase,项目名称:friendlypix-android,代码行数:20,代码来源:ProfileActivity.java

示例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;
    }
}
 
开发者ID:firebase,项目名称:friendlypix-android,代码行数:27,代码来源:WelcomeActivity.java

示例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();
                }
            });
}
 
开发者ID:rajatdb,项目名称:FirebaseChatApp,代码行数:23,代码来源:MainActivity.java

示例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);
                }
            });
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:21,代码来源:MainActivity.java

示例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]
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:26,代码来源:DocSnippets.java

示例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);
            }
         });
      }
   });
}
 
开发者ID:DVT,项目名称:showcase-android,代码行数:26,代码来源:RxFirebaseDatabase.java

示例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();
}
 
开发者ID:AmeliaPessoa,项目名称:DBPA,代码行数:18,代码来源:Firebase.java


注:本文中的com.google.android.gms.tasks.OnFailureListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。