在特定时间重新启动 activity

Restart an activity on a particular time

我正在开发一个应用程序,我需要在特定时间 refresh/restart 我的 menuPage activity。例如下午 12 点。 我怎样才能实现它。 注意:如果用户在中午 12 点之前使用旧菜单使用我的应用程序并且他在使用我的应用程序时已经过了中午 12 点时间,则菜单页面需要在中午 12 点重新启动。 如果应用程序关闭,则无需重新启动应用程序。 由于我的菜单在下午 12 点后更改,因此客户在中午 12 点之前和中午 12 点之后使用我的应用程序。所以用户需要在中午12点以后看到更新的菜单

请阅读以下链接

希望对你有帮助。

这肯定有效,100%...

final long delayMillis=1000;
Handler h=null;
Runnable r;

在 onCreate() 中

h=new Handler(Looper.getMainLooper());
    r = new Runnable() {

           public void run() {

               //current time
               Calendar c = Calendar.getInstance(); 
                int hour = c.get(Calendar.HOUR_OF_DAY);
                int min=c.get(Calendar.MINUTE);
                int sec=c.get(Calendar.SECOND);
                String currenttime= String.valueOf(hour)+" : "+String.valueOf(min)+" : "+String.valueOf(sec);


             //comparing current time with 12:00pm
               if(currenttime.equals("12 : 0 : 0")){

                 //restarting the activity
                   Intent intent = getIntent();
                   finish();
                   startActivity(intent);

               }


            h.postDelayed(this, delayMillis);

        }
      };

    h.post(r);

祝一切顺利..