I'm coding a game to play online throught the firestore service. It's a one to one game. The game works correctly, but the problem is that in the player one device the app continously call to the onCreate method in the Android Activity and the screen is reloaded completely.
In the logcat appear:
V/FA: Inactivity, disconnecting from the service
But this problem only appear in one device. In the player one device, not in the player two.
In another thread the people say that the problem is with the Android Studio cache, but it doesn't works for me: V/FA: Inactivity, disconnecting from the service
private void gameListener() {
listenerJugadas = db.collection("games")
.document(gameId)
.addSnapshotListener(GameActivity.this, new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@Nullable DocumentSnapshot snapshot, @Nullable FirebaseFirestoreException e) {
if (e != null) {
Toast.makeText(GameActivity.this, "Error while loading!", Toast.LENGTH_SHORT).show();
Log.d("TAG", e.toString());
return;
}
String source = snapshot != null && snapshot.getMetadata().hasPendingWrites()
? "Local" : "Server";
if(snapshot.exists() && source == "Server") {
jugada = snapshot.toObject(Jugada.class);
if(playerOneName.isEmpty() || playerTwoName.isEmpty()) {
getPlayerNames();
}
updateUI();
}
}
});
}