【发布时间】:2020-05-16 20:06:09
【问题描述】:
您好,我想在特定时间使用 countDownTimer 在 Firestore 上设置特定数据。当我的倒计时完成时,数据在 firestore 上设置得很好,但每次更新活动时,数据都会一次又一次地重置。 当我的数据设置一次时,是否有可能破坏完成方法?如果您有其他建议欢迎您
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();
}
}
【问题讨论】:
标签: java android google-cloud-firestore countdowntimer