2015-09-07 134 views
0

我對Android非常陌生,並計劃在特定時間開發一款應用程序。我已閱讀過有關AlarmManager,意圖和廣播接收器的信息。 我已經看到並從其他線程運行一些示例代碼,並能夠運行它們。這些樣本正在發送通知和文本(通過吐司)。使用AlarmManager啓動Android應用程序

但我的問題是,是否可以啓動我的應用程序,即顯示我的應用程序的主屏幕上的時間,我已經設置使用AlarmManager?如果是的話,我該怎麼做?

我真的很感謝你的幫助。

在此先感謝..

+0

顯示你到目前爲止編的代碼 – injecteer

+0

是的,這是可能的,但你有什麼嘗試? –

回答

0

是的,這是可能的。以下代碼正在爲我工​​作。

Intent intent = new Intent(this, YOUR_MAIN_ACTIVITY.class); 
       intent.setAction(Intent.ACTION_MAIN); 
       intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 
       PendingIntent pendingIntent = PendingIntent.getActivity(this, ID, 
         intent, 0); 

       final long DELAY_IN_MILLIS = DELAY_IN_MILLI_SECONDS+ System.currentTimeMillis(); 
       AlarmManager alarmManager = (AlarmManager) 
         getSystemService(Activity.ALARM_SERVICE); 
       alarmManager.set(AlarmManager.RTC, DELAY_IN_MILLIS,pendingIntent);