I have a problem in my code on android.
I tried to use Firebase Realtime Database
to have a cloud based where I can update a data instantly in return it to me instantly but the the problem is it's only execute the code that i want when the screen is on.
What i need is I want to execute a line of code everytime a data has been changed while the screen is off, is that possible ?
thanks everybody
@Override
protected void onStart(){
super.onStart();
mref = new Firebase("https://connection-4f6d8.firebaseio.com/condition"+a_id);
mref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String text = dataSnapshot.getValue(String.class);
if(text.equals("UNLOCKED")){
sendDataonWIfi("0");
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
@Override
protected void onStop() {
super.onStop();
mref = new Firebase("https://connection-4f6d8.firebaseio.com/condition"+a_id);
mref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String text = dataSnapshot.getValue(String.class);
if(text.equals("UNLOCKED")){
sendDataonWIfi("0");
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}