CountDownTimer (2000, 0000) {
@Override
public void onTick(long millisUntilFinished) {}
@Override
public void onFinish() {
txt1.setText("...");
txt1.setVisibility(View.VISIBLE);
txt2.setText("...");
txt2.setVisibility(View.VISIBLE);
cancel(); //<----it deletes the Countdown Timer after finished
}
}.start();
我将cancel()
放入onFinish()
。所以当倒计时结束时,它会自行删除。
但是,当我关闭并重新启动应用程序时,活动从头开始,以及计时器。
我怎样才能让它运作一次?
答案 0 :(得分:1)
不,你不能这样做。当你重新开始Tamir.SharpSsh.Sftp ClientSFTP = new Tamir.SharpSsh.Sftp(pHost, pUserName, pPassword);
try
{
string FechaActual = DateTime.Today.ToString("yyyyMMdd");
string pFilePEDIMENTOS = "/local/opt/oracle/oradata/UTL_DIR/PEDIMENTOS/pedimento.csv";
string pFilePROCESADO = "/local/opt/oracle/oradata/UTL_DIR/PEDIMENTOS/PROCESADO/pedimento" + FechaActual + ".csv";
//Abre sesion
ClientSFTP.Connect();
if (ClientSFTP.Connected)
{
// ejecutar el comando
ClientSFTP.Put(pFilePEDIMENTOS, pFilePROCESADO);//SEGUIR INVESTIGANDO
}
else
{
throw new Exception("Error de Conexion con el Servidor Remoto");
}
}
catch (Exception ex)
{
lblError.Text = ex.Message;
}
finally
{
//cerrar conexion SFTP
ClientSFTP.Close();
}
时,你创建了一个新的application
。如果你想实现它,请尝试将状态存储在timer
。
SharedPrefense