I want to open a specific activity based on the data I retrieve from the firebase realtime database...
Firebase.setAndroidContext(this);
mRef=new Firebase("https://test-new-f2637.firebaseio.com/Name");
mValueView=(TextView) findViewById(R.id.valueView);
btn=(Button) findViewById(R.id.button);
mRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
value = dataSnapshot.getValue(String.class);
mValueView.setText(value);
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String n=mValueField.getText().toString();
if(n=="yes")
{
func1();
}
else
{
func2();
}
}
});
}
public void func1()
{
Intent intent = new Intent(this, first.class);
startActivity(intent);
}
public void func2()
{
Intent intent = new Intent(this, second.class);
startActivity(intent);
}
}
If I retrieve "yes" from the firebase databse then the first activity should be opened or else the second activity should open.
But the problem is that by retrieving the value as "yes" then also the second activity is opening
PS:-I'am new to android and firebase