I am doing the final project of DAM and in the app that I am creating I would like to know how I can load an activity through a code that exists in the database. I'm working with Firebase and this is the method I'm using.
public void joinEvent(View view) {
codigo=Codigo.getText().toString();
DatabaseReference root = FirebaseDatabase.getInstance().getReference();
DatabaseReference events = root.child("Events");
events.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
if (snapshot.child(codigo).exists()) {
// run some code
}else {
Toast.makeText( context, "Código Invalido", Toast.LENGTH_SHORT ).show();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Intent intent = new Intent(this, EventActivity.class);
// intent.putExtra("code",mCode.getText().toString());
startActivity(intent);
}