2011-11-24 197 views
1

在Android手机闲置60秒后,是否有任何可能让应用程序自行重新启动?Android上的itseft应用程序启动

这是我的尝试:

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); 


    } 

} 

,但不工作。

+0

检查此。你可以获得一个自动启动应用程序的想法 http://stackoverflow.com/questions/1056570/how-to-autostart-an-android-application – mobileDeveloper

回答

4

是使用闹钟管理器唤醒它...您可以使用后台服务中的闹钟管理器或其他东西,然后让应用程序打开。

+1

你能给我一个例子吗? – Gabrielle

+0

[链接](http://stackoverflow.com/q/4739222/696145)这是用户不希望你想要的例子...所以要指导的问题..如果你想我会做一点点更深入地与你一起专门针对你需要的场景,但我需要更多地了解需求和类似的东西...... – medampudi