2011-11-24 193 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