0

一段时间后我需要重新启动我的android。我的应用程序是带有图像的幻灯片。用户通过主页按钮或返回按钮关闭应用程序。我需要在一段时间后重新启动应用程序(在丢失的用户触摸设备几分钟后 - 就像屏幕保护程序一样)。是否有可能做到这一点?谁能帮助我我该怎么做?

4

2 回答 2

0

我不确定这是个好主意。如果你的用户想退出你的应用,你为什么要把它带到最前面呢?

但是,我认为您可以使用后台服务来实现这一点,该服务会在一定时间后启动Intent 。

于 2013-06-11T08:18:45.637 回答
0

恕我直言,最好的解决方案是警报管理器。 http://developer.android.com/reference/android/app/AlarmManager.html 示例:

long nexttime = (new Date()).getTime() + 60L*60L*1000L;//one hour after.

    AlarmManager am=(AlarmManager)getSystemService(Activity.ALARM_SERVICE);
            Intent intent = new Intent(this, MyService.class);
            intent.putExtra(SomeExtras, false);//for instance
            PendingIntent pi = PendingIntent.getService(this, 12345, intent, PendingIntent.FLAG_CANCEL_CURRENT);
            am.set(AlarmManager.RTC,nexttime, pi);
于 2013-06-11T08:24:24.190 回答