2015-07-06 170 views
1

AlarmManeger在重新啓動後不啓動,但它應該。 我該怎麼辦? AndroidManifest:Android - 重新啓動後啓動AlarmManager

<uses-permission android:name="android.permission.WAKE_LOCK" /> 
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 

    <receiver android:name=".AlarmEngine.AlarmManagerHelper" > 
     <intent-filter> 
      <action android:name="android.intent.action.BOOT_COMPLETED"></action> 
     </intent-filter> 
    </receiver> 

廣播接收器:

@Override 
    public void onReceive(Context context, Intent intent) 
    { 
     setAlarms(context); 
    } 

public static void setAlarms(Context context) 
{ 
    cancelAlarms(context); 
    AlarmDBHelper dbHelper = new AlarmDBHelper(context); 
    List<AlarmModel> alarms = dbHelper.getAlarms(); 

     for (AlarmModel alarm : alarms) 
     { 
       PendingIntent pIntent = createPendingIntent(context, alarm); 
... 
     alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pIntent); 

回答

0

我固定它移動應用手機的內存。

我替換此:

android:installLocation="preferExternal" > 

在此:

android:installLocation="internalOnly" >