1

Android手机闲置60秒后,是否有可能让应用程序自行重启?

这是我尝试过的:

public class BootUpReceiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {
        Intent i = new Intent(context, SplashScreen.class);
        PendingIntent pi = PendingIntent.getService(context, 0, i, 0);
        AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        am.cancel(pi); // cancel any existing alarms
        am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
            SystemClock.elapsedRealtime() +60000,
            AlarmManager.INTERVAL_DAY, pi);


    }

} 

但不工作。

4

2 回答 2

4

是的,使用警报管理器将其唤醒...您可以在后台服务或其他东西中使用警报管理器,然后打开应用程序。

于 2011-11-24T12:11:56.973 回答
1

您还可以利用异步类

http://labs.makemachine.net/2010/05/android-asynctask-example/

在 onPostExecute 你可以随心所欲。

于 2011-11-24T14:26:42.630 回答