我尝试在Firebase连接的Android应用中实施Google登录.当我运行应用程序并按Google登录按钮时 - 没有任何反应.我在onActivityResult中收到此错误: Status {statusCode = DEVELOPER_ERROR,resolution = null}.
我的代码看起来像这样:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_GOOGLE_LOGIN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()){
GoogleSignInAccount account = result.getSignInAccount();
String emailAddres = account.getEmail();
getGoogleQAuthToken(emailAddres);
}
}
}
private void getGoogleQAuthToken(final String emailAddres){
AsyncTask<Void,Void,String> task = new AsyncTask<Void, Void, String>() {
String errorMessage = null;
@Override
protected String doInBackground(Void... params) {
String token = null;
try {
String scope = "oauth2:profile email";
token = GoogleAuthUtil.getToken(MainActivity.this, …Run Code Online (Sandbox Code Playgroud) android google-authentication firebase firebase-authentication firebaseui
我尝试开发一个简单的购物应用程序.将有一些产品类别,我对每个类别使用ListView的不同活动.当用户选择产品类别(比如items1 ="drink")时 - 新的屏幕打开,他可以添加"soda","cola"......我想在每个类别上添加计数徽章,以显示每个类别的产品数量.因此,例如对于"项目"我需要显示5,对于"items1" - 2和对于"items10/11" - 显示1:
我的ActivityItems1代码:
private Firebase mRef;
private String mUserId;
private String itemsUrl;
private TextView badge;
itemsUrl = Constants.FIREBASE_URL + "/users/" + mUserId + "/items1";
// Set up LisView
final ListView listView = (ListView) findViewById(R.id.listView);
final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1);
listView.setAdapter(adapter);
// Find badge
badge =(TextView)findViewById(R.id.badgeView);
// Use Firebase to populate the list.
new Firebase(itemsUrl)
.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
adapter.add((String) dataSnapshot.child("title").getValue());
Log.e(dataSnapshot.getKey(), dataSnapshot.getChildrenCount() + ""); …Run Code Online (Sandbox Code Playgroud)