我是firebase的新手.我试图将我的应用程序中列出的用户的属性保存到数据库中Firebase
,这是代码
mAuthListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { firebaseuser = firebaseAuth.getCurrentUser(); if (firebaseuser != null) { finish(); firebaseuser = mAuth.getCurrentUser(); String nama = firebaseuser.getDisplayName(); String mail = firebaseuser.getEmail(); //String pass = password.getText().toString(); String id = firebaseuser.getUid(); //Uri gambar = firebaseuser.getPhotoUrl(); member1 = new Member(nama, mail, "", "belum", "belum", "belum", id); datab.getReference("member").push().setValue(member1); startActivity(new Intent(getApplicationContext(), HalamanUtama.class)); } } };
这里的问题是当我使用Google登录进入我的应用程序时,我无法将使用google登录到我的应用程序的用户的信息保存到我的firebase数据库,但我可以使用电子邮件方法保存用户的登录信息.这是使用电子邮件进入我的应用程序的代码
mAuth.createUserWithEmailAndPassword(email.getText().toString(), password.getText().toString()) .addOnCompleteListener(HalamanPendaftaran.this, new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if (task.isSuccessful()) { progressdialog.dismiss(); finish(); firebaseuser = mAuth.getCurrentUser(); String nama = firebaseuser.getDisplayName(); String mail = firebaseuser.getEmail(); String pass = password.getText().toString(); String id = firebaseuser.getUid(); Uri gambar = firebaseuser.getPhotoUrl(); member1 = new Member(nama, mail, pass, "belum", "belum", "belum", id, gambar); datab.getReference("member").push().setValue(member1); startActivity(new Intent(HalamanPendaftaran.this, HalamanUtama.class)); } else { progressdialog.dismiss(); Toast.makeText(HalamanPendaftaran.this, "tidak dapat mendaftarkan user, tolong coba lagi !", Toast.LENGTH_SHORT).show(); email.setText(""); password.setText(""); } } });
至于我在尝试存储使用谷歌登录的用户数据时遇到的错误
01-10 18:42:00.619 8218-8218/com.example.asus.fastapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.asus.fastapp, PID: 8218 java.lang.StackOverflowError: stack size 8MB at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source) at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source) at com.google.android.gms.internal.zzbqi.zzax(Unknown Source) at com.google.android.gms.internal.zzbqi.zzaE
这是成功保存Firebase数据库数据的用户的 数据之一
任何帮助将不胜感激
您的Member
类包含一个类型的字段Uri
. Uri
不是Firebase序列化的本机类型之一.
更改您的Member
类以将Uri存储为String并使用Uri.toString()和Uri.parse()进行转换.