How can I put Firebase database code into my Frebase auth code? [closed]
How can I put Firabase Database code into my Frebase auth code? so that the data will only save into the database if there are no errors or onComplete.
Firebase database code:
if (!nameStr.isEmpty())
String ID = GDatabase.push().getKey();
Accounts accounts = new Accounts(ID, nameStr, genderStr, emailStr, passwordStr);
GDatabase.child(ID).setValue(accounts);
else
Toast.makeText(MainActivity.this, "Unable to save data into the database", Toast.LENGTH_SHORT).show();
Firebase auth code:
firebaseAuth.createUserWithEmailAndPassword(emailStr, passwordStr)
.addOnCompleteListener(new OnCompleteListener<AuthResult>()
@Override
public void onComplete(@NonNull Task<AuthResult> task)
progressBar.setVisibility(View.GONE);
if (task.isSuccessful())
firebaseAuth.getCurrentUser().sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>()
@Override
public void onComplete(@NonNull Task<Void> task)
if (task.isSuccessful())
Toast.makeText(MainActivity.this, "Registered successfully. Please check your email for verification",
Toast.LENGTH_LONG).show();
email.setText("");
password.setText("");
else
Toast.makeText(MainActivity.this, task.getException().getMessage(),
Toast.LENGTH_LONG).show();
);
);
All of my code from that class:
public class MainActivity extends AppCompatActivity $%&*!+-*/=.,;'<>?`()_à «±ê ¸â¯â°â±â²âÂÂâºâÂÂÃÂÃÂ0123456789ÃÂÃÂêÂÂäÃÂââÂ¥â¦â§" +
"âªâ¶â·â¸âÂ
ÂâÂ
ÂâÂÂâÂÂâÂÂâÂÂâÂÂâ®âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¦á¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶ÂᶸᵯᵰᵴᵶᵹᵼᵽᵾᵿâÂÂu200Cu200Du200Eu200Fâ¯âÂÂâÂÂ" +
"u206Au206Bu206Cu206Du206Eu206Fâ¸Ââ¸ÂöÃ¥ãâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â§â¨â©âª" +
"â«â‰ÂÂâ®â¯â°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â¨â©âªâ§â«â‰ÂÂâ®â¯â°" +
"â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿â°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â
â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â" +
"â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â⤠⤡⤢⤣⤤⤥⤦⤧⤨⤩⤪⤫⤬â¤Â⤮⤯⤰⤱⤲⤳⤴⤵⤶⤷⤸⤹⤺⤻⤼⤽⤾⤿â¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Â
â¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Â" +
"⥠⥡⥢⥣⥤⥥⥦⥧⥨⥩⥪⥫⥬â¥Â⥮⥯⥰⥱⥲⥳⥴⥵⥶⥷⥸⥹⥺⥻⥼⥽⥾⥿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â§â¨â©â©âªâ«â‰ÂÂâ®â¯â±â²â³" +
"â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Â
â¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬ÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¾âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¤âÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ" +
"âÂÂâ¢â£â¯â‰ÂÂâ®âÂÂâ°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â¯â°â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ âÂÂâ¡â¢â£â¤âÂ¥â¨â©â¦â§â‰¿âªâ®â«â±â²âÂÂâ³â´âµâ¶â·â¸â¹âºâ¼â½â¾âÂÂâÂÂâÂÂâÂÂ" +
"âÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ£âÂÂâÂ¥â¢âÂÂâ²â³â´âµâ¶â¸â¹âºâÂȉ¼â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¤âÂÂâÂÂâÂÂâ°â¦!âÂÂâÂÂâÂÂâÂÂëÃȉ¹âºâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂãåâ¬$" +
"âìö@çîéâ¢ðÃÂÃÂñâÂÂâ°éâÂÂâÂÂ÷~â ùòóýüþâÂÂâÂÂâÂÂ
java android firebase firebase-realtime-database firebase-authentication
closed as unclear what you're asking by Frank van Puffelen, Doug Stevenson, Nicholas K, Martin Zeitler, Alex Mamo Nov 12 at 19:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |Â
How can I put Firabase Database code into my Frebase auth code? so that the data will only save into the database if there are no errors or onComplete.
Firebase database code:
if (!nameStr.isEmpty())
String ID = GDatabase.push().getKey();
Accounts accounts = new Accounts(ID, nameStr, genderStr, emailStr, passwordStr);
GDatabase.child(ID).setValue(accounts);
else
Toast.makeText(MainActivity.this, "Unable to save data into the database", Toast.LENGTH_SHORT).show();
Firebase auth code:
firebaseAuth.createUserWithEmailAndPassword(emailStr, passwordStr)
.addOnCompleteListener(new OnCompleteListener<AuthResult>()
@Override
public void onComplete(@NonNull Task<AuthResult> task)
progressBar.setVisibility(View.GONE);
if (task.isSuccessful())
firebaseAuth.getCurrentUser().sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>()
@Override
public void onComplete(@NonNull Task<Void> task)
if (task.isSuccessful())
Toast.makeText(MainActivity.this, "Registered successfully. Please check your email for verification",
Toast.LENGTH_LONG).show();
email.setText("");
password.setText("");
else
Toast.makeText(MainActivity.this, task.getException().getMessage(),
Toast.LENGTH_LONG).show();
);
);
All of my code from that class:
public class MainActivity extends AppCompatActivity $%&*!+-*/=.,;'<>?`()_à «±ê ¸â¯â°â±â²âÂÂâºâÂÂÃÂÃÂ0123456789ÃÂÃÂêÂÂäÃÂââÂ¥â¦â§" +
"âªâ¶â·â¸âÂ
ÂâÂ
ÂâÂÂâÂÂâÂÂâÂÂâÂÂâ®âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¦á¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶ÂᶸᵯᵰᵴᵶᵹᵼᵽᵾᵿâÂÂu200Cu200Du200Eu200Fâ¯âÂÂâÂÂ" +
"u206Au206Bu206Cu206Du206Eu206Fâ¸Ââ¸ÂöÃ¥ãâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â§â¨â©âª" +
"â«â‰ÂÂâ®â¯â°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â¨â©âªâ§â«â‰ÂÂâ®â¯â°" +
"â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿â°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â
â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â" +
"â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â⤠⤡⤢⤣⤤⤥⤦⤧⤨⤩⤪⤫⤬â¤Â⤮⤯⤰⤱⤲⤳⤴⤵⤶⤷⤸⤹⤺⤻⤼⤽⤾⤿â¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Â
â¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Â" +
"⥠⥡⥢⥣⥤⥥⥦⥧⥨⥩⥪⥫⥬â¥Â⥮⥯⥰⥱⥲⥳⥴⥵⥶⥷⥸⥹⥺⥻⥼⥽⥾⥿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â§â¨â©â©âªâ«â‰ÂÂâ®â¯â±â²â³" +
"â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Â
â¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬ÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¾âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¤âÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ" +
"âÂÂâ¢â£â¯â‰ÂÂâ®âÂÂâ°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â¯â°â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ âÂÂâ¡â¢â£â¤âÂ¥â¨â©â¦â§â‰¿âªâ®â«â±â²âÂÂâ³â´âµâ¶â·â¸â¹âºâ¼â½â¾âÂÂâÂÂâÂÂâÂÂ" +
"âÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ£âÂÂâÂ¥â¢âÂÂâ²â³â´âµâ¶â¸â¹âºâÂȉ¼â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¤âÂÂâÂÂâÂÂâ°â¦!âÂÂâÂÂâÂÂâÂÂëÃȉ¹âºâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂãåâ¬$" +
"âìö@çîéâ¢ðÃÂÃÂñâÂÂâ°éâÂÂâÂÂ÷~â ùòóýüþâÂÂâÂÂâÂÂ
java android firebase firebase-realtime-database firebase-authentication
closed as unclear what you're asking by Frank van Puffelen, Doug Stevenson, Nicholas K, Martin Zeitler, Alex Mamo Nov 12 at 19:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
What are you stuck on in particular?
â halfer
Nov 10 at 21:21
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
â Patrick Mangubat
Nov 11 at 2:40
Sotask.isSuccessful()
istrue
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).
â halfer
Nov 11 at 10:14
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
â Patrick Mangubat
Nov 11 at 12:27
add a comment |Â
How can I put Firabase Database code into my Frebase auth code? so that the data will only save into the database if there are no errors or onComplete.
Firebase database code:
if (!nameStr.isEmpty())
String ID = GDatabase.push().getKey();
Accounts accounts = new Accounts(ID, nameStr, genderStr, emailStr, passwordStr);
GDatabase.child(ID).setValue(accounts);
else
Toast.makeText(MainActivity.this, "Unable to save data into the database", Toast.LENGTH_SHORT).show();
Firebase auth code:
firebaseAuth.createUserWithEmailAndPassword(emailStr, passwordStr)
.addOnCompleteListener(new OnCompleteListener<AuthResult>()
@Override
public void onComplete(@NonNull Task<AuthResult> task)
progressBar.setVisibility(View.GONE);
if (task.isSuccessful())
firebaseAuth.getCurrentUser().sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>()
@Override
public void onComplete(@NonNull Task<Void> task)
if (task.isSuccessful())
Toast.makeText(MainActivity.this, "Registered successfully. Please check your email for verification",
Toast.LENGTH_LONG).show();
email.setText("");
password.setText("");
else
Toast.makeText(MainActivity.this, task.getException().getMessage(),
Toast.LENGTH_LONG).show();
);
);
All of my code from that class:
public class MainActivity extends AppCompatActivity $%&*!+-*/=.,;'<>?`()_à «±ê ¸â¯â°â±â²âÂÂâºâÂÂÃÂÃÂ0123456789ÃÂÃÂêÂÂäÃÂââÂ¥â¦â§" +
"âªâ¶â·â¸âÂ
ÂâÂ
ÂâÂÂâÂÂâÂÂâÂÂâÂÂâ®âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¦á¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶ÂᶸᵯᵰᵴᵶᵹᵼᵽᵾᵿâÂÂu200Cu200Du200Eu200Fâ¯âÂÂâÂÂ" +
"u206Au206Bu206Cu206Du206Eu206Fâ¸Ââ¸ÂöÃ¥ãâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â§â¨â©âª" +
"â«â‰ÂÂâ®â¯â°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â¨â©âªâ§â«â‰ÂÂâ®â¯â°" +
"â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿â°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â
â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â" +
"â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â⤠⤡⤢⤣⤤⤥⤦⤧⤨⤩⤪⤫⤬â¤Â⤮⤯⤰⤱⤲⤳⤴⤵⤶⤷⤸⤹⤺⤻⤼⤽⤾⤿â¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Â
â¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Â" +
"⥠⥡⥢⥣⥤⥥⥦⥧⥨⥩⥪⥫⥬â¥Â⥮⥯⥰⥱⥲⥳⥴⥵⥶⥷⥸⥹⥺⥻⥼⥽⥾⥿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â§â¨â©â©âªâ«â‰ÂÂâ®â¯â±â²â³" +
"â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Â
â¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬ÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¾âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¤âÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ" +
"âÂÂâ¢â£â¯â‰ÂÂâ®âÂÂâ°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â¯â°â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ âÂÂâ¡â¢â£â¤âÂ¥â¨â©â¦â§â‰¿âªâ®â«â±â²âÂÂâ³â´âµâ¶â·â¸â¹âºâ¼â½â¾âÂÂâÂÂâÂÂâÂÂ" +
"âÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ£âÂÂâÂ¥â¢âÂÂâ²â³â´âµâ¶â¸â¹âºâÂȉ¼â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¤âÂÂâÂÂâÂÂâ°â¦!âÂÂâÂÂâÂÂâÂÂëÃȉ¹âºâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂãåâ¬$" +
"âìö@çîéâ¢ðÃÂÃÂñâÂÂâ°éâÂÂâÂÂ÷~â ùòóýüþâÂÂâÂÂâÂÂ
java android firebase firebase-realtime-database firebase-authentication
How can I put Firabase Database code into my Frebase auth code? so that the data will only save into the database if there are no errors or onComplete.
Firebase database code:
if (!nameStr.isEmpty())
String ID = GDatabase.push().getKey();
Accounts accounts = new Accounts(ID, nameStr, genderStr, emailStr, passwordStr);
GDatabase.child(ID).setValue(accounts);
else
Toast.makeText(MainActivity.this, "Unable to save data into the database", Toast.LENGTH_SHORT).show();
Firebase auth code:
firebaseAuth.createUserWithEmailAndPassword(emailStr, passwordStr)
.addOnCompleteListener(new OnCompleteListener<AuthResult>()
@Override
public void onComplete(@NonNull Task<AuthResult> task)
progressBar.setVisibility(View.GONE);
if (task.isSuccessful())
firebaseAuth.getCurrentUser().sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>()
@Override
public void onComplete(@NonNull Task<Void> task)
if (task.isSuccessful())
Toast.makeText(MainActivity.this, "Registered successfully. Please check your email for verification",
Toast.LENGTH_LONG).show();
email.setText("");
password.setText("");
else
Toast.makeText(MainActivity.this, task.getException().getMessage(),
Toast.LENGTH_LONG).show();
);
);
All of my code from that class:
public class MainActivity extends AppCompatActivity $%&*!+-*/=.,;'<>?`()_à «±ê ¸â¯â°â±â²âÂÂâºâÂÂÃÂÃÂ0123456789ÃÂÃÂêÂÂäÃÂââÂ¥â¦â§" +
"âªâ¶â·â¸âÂ
ÂâÂ
ÂâÂÂâÂÂâÂÂâÂÂâÂÂâ®âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¦á¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶Âá¶ÂᶸᵯᵰᵴᵶᵹᵼᵽᵾᵿâÂÂu200Cu200Du200Eu200Fâ¯âÂÂâÂÂ" +
"u206Au206Bu206Cu206Du206Eu206Fâ¸Ââ¸ÂöÃ¥ãâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂÂâÂ
ÂâÂ
ÂâÂ
ÂâÂ
ÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â§â¨â©âª" +
"â«â‰ÂÂâ®â¯â°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â¨â©âªâ§â«â‰ÂÂâ®â¯â°" +
"â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿â°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¿â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â
â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â" +
"â¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Ââ¤Â⤠⤡⤢⤣⤤⤥⤦⤧⤨⤩⤪⤫⤬â¤Â⤮⤯⤰⤱⤲⤳⤴⤵⤶⤷⤸⤹⤺⤻⤼⤽⤾⤿â¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Â
â¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Ââ¥Â" +
"⥠⥡⥢⥣⥤⥥⥦⥧⥨⥩⥪⥫⥬â¥Â⥮⥯⥰⥱⥲⥳⥴⥵⥶⥷⥸⥹⥺⥻⥼⥽⥾⥿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ â¡â¢â£â¤âÂ¥â¦â§â¨â©â©âªâ«â‰ÂÂâ®â¯â±â²â³" +
"â´âµâ¶â·â¸â¹âºâÂȉ¼â½â¾â¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Â
â¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬Ââ¬ÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¾âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¤âÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ" +
"âÂÂâ¢â£â¯â‰ÂÂâ®âÂÂâ°â±â²â³â´âµâ¶â·â¸â¹âºâÂȉ¼â¯â°â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ âÂÂâ¡â¢â£â¤âÂ¥â¨â©â¦â§â‰¿âªâ®â«â±â²âÂÂâ³â´âµâ¶â·â¸â¹âºâ¼â½â¾âÂÂâÂÂâÂÂâÂÂ" +
"âÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ£âÂÂâÂ¥â¢âÂÂâ²â³â´âµâ¶â¸â¹âºâÂȉ¼â½â¾â¿âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂ
âÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâ¤âÂÂâÂÂâÂÂâ°â¦!âÂÂâÂÂâÂÂâÂÂëÃȉ¹âºâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂâÂÂãåâ¬$" +
"âìö@çîéâ¢ðÃÂÃÂñâÂÂâ°éâÂÂâÂÂ÷~â ùòóýüþâÂÂâÂÂâÂÂ
java android firebase firebase-realtime-database firebase-authentication
java android firebase firebase-realtime-database firebase-authentication
edited Nov 10 at 21:20
halfer
14.3k758109
14.3k758109
asked Nov 10 at 14:12
Patrick Mangubat
245
245
closed as unclear what you're asking by Frank van Puffelen, Doug Stevenson, Nicholas K, Martin Zeitler, Alex Mamo Nov 12 at 19:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Frank van Puffelen, Doug Stevenson, Nicholas K, Martin Zeitler, Alex Mamo Nov 12 at 19:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
What are you stuck on in particular?
â halfer
Nov 10 at 21:21
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
â Patrick Mangubat
Nov 11 at 2:40
Sotask.isSuccessful()
istrue
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).
â halfer
Nov 11 at 10:14
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
â Patrick Mangubat
Nov 11 at 12:27
add a comment |Â
What are you stuck on in particular?
â halfer
Nov 10 at 21:21
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
â Patrick Mangubat
Nov 11 at 2:40
Sotask.isSuccessful()
istrue
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).
â halfer
Nov 11 at 10:14
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
â Patrick Mangubat
Nov 11 at 12:27
What are you stuck on in particular?
â halfer
Nov 10 at 21:21
What are you stuck on in particular?
â halfer
Nov 10 at 21:21
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
â Patrick Mangubat
Nov 11 at 2:40
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
â Patrick Mangubat
Nov 11 at 2:40
So
task.isSuccessful()
is true
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).â halfer
Nov 11 at 10:14
So
task.isSuccessful()
is true
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).â halfer
Nov 11 at 10:14
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
â Patrick Mangubat
Nov 11 at 12:27
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
â Patrick Mangubat
Nov 11 at 12:27
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
What are you stuck on in particular?
â halfer
Nov 10 at 21:21
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
â Patrick Mangubat
Nov 11 at 2:40
So
task.isSuccessful()
istrue
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).â halfer
Nov 11 at 10:14
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
â Patrick Mangubat
Nov 11 at 12:27