0

我希望在 systemTime 等于特定值时立即执行 newCradleLoading 的 stop 方法。

这是我的伪代码:

 newtonCradleLoading.start();
    Calendar rightNow = Calendar.getInstance();
    Calendar en = Calendar.getInstance();
    en.set(2015, 10, 20, 21, 48, 00);
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String formattedDate = df.format(rightNow.getTime());
    String reqd = df.format(en.getTime());
    while (formattedDate != reqd) {
        rightNow = Calendar.getInstance();
        formattedDate = df.format(rightNow.getTime());
    }
 newtonCradleLoading.stop();

问题是,一旦我选择显示此片段的选项,应用程序就会冻结。

该库可以在以下位置找到:https ://github.com/yankai-victor/Loading

为了更清楚,我希望看到 Newton Cradle running ,直到 systemTime 等于所需的时间和日期。

谢谢!

4

1 回答 1

0

您是否查看过 AlarmManager 服务?

这是如何在 android 开发者网站http://developer.android.com/training/scheduling/alarms.html上使用它的示例

于 2015-10-20T17:15:51.103 回答