I’m studying Android Studio and Firebase to a do simple app. And is almost working.
How can I grab data from firebase and store it in one Variable to check user level?
"Users" : { "S7TEROObjae8RfsMEbmylTmiJqS2" : { "email" : "testd@test.com", "fullName" : "doug", "ident" : "associado" }
So if the user has Value Ident = “associado” should be followed to AssociadoActivity.
Right now everyone is sent to AdminActivity.
mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if(task.isSuccessful()){ if(user.isEmailVerified()) { startActivity(new Intent(MainActivity.this, AdminActivity.class)); } else { user.sendEmailVerification(); } progressBar.setVisibility(View.GONE); } else { Toast.makeText(MainActivity.this, "O login não pode ser efetuado", Toast.LENGTH_SHORT).show(); } } });
Advertisement
Answer
Read this article to get data from firebase link
then just save your data in local storage like Preferencemanager
then open your activity according to your condition