Hello i want to set a particular data on firestore at a specific time using countDownTimer. When my countDown finish, the data is well set on firestore but each time the activity is update, the data is reset again and again. Please there is a possible way to destroy the finish method when my data is set once ?. if you have other suggestion to give your welcome
firebaseAuth=FirebaseAuth.getInstance();
firebaseFirestore=FirebaseFirestore.getInstance();
long mil=200000;
downTimer =new CountDownTimer(mil,1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
Map<String,Object> map=new HashMap<>();
map.put("Password","userPassword");
firebaseFirestore.collection("UsersName").document().set(map).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(ForgetPasswordActivity.this, "Done sir", Toast.LENGTH_SHORT).show();
downTimer.cancel();
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
e.printStackTrace();
}
});
}
}.start();
}
}