1
//Alaramkt
public class Alaramkt extends BroadcastReceiver{

@Override
public void onReceive(Context context, Intent arg1) {
    // TODO Auto-generated method stub
    Log.e("Location start", "Location startlllllll");
    Intent alarm1 = new Intent(context, LocationReceiver.class);
    boolean alarmRunning1 = (PendingIntent.getBroadcast(context, 0, alarm1,
            PendingIntent.FLAG_NO_CREATE) != null);
if (alarmRunning1 == false) {
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
                0, alarm1, 0);
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
                SystemClock.elapsedRealtime(), 5000, pendingIntent);

    }
}

}



//Location receiver


public class LocationReceiver extends BroadcastReceiver{

@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    Log.e("Location start", "Location start");
    System.gc();
    Intent background = new Intent(context, BackgroundReceiverService.class);
    context.startService(background);
}


}


//Manifestfile

   <receiver android:name="com.main.service.LocationReceiver" >
    </receiver>  


    <receiver
    android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
    android:enabled="true"
    android:exported="true"
    android:process=":remote"
    android:name="com.main.service.Alaramkt">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <action android:name="Alaramkt"/>
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</receiver>




    <receiver  android:process=":remote" android:name="com.main.service.Alaramkt"></receiver>

   // 

Here what missing above code. once app closed (That means heap space remove the app) and device rebooted after not work receiver

Evgeniy Mishustin
  • 3,343
  • 3
  • 42
  • 81
Abi K
  • 17
  • 5
  • Possible duplicate of http://stackoverflow.com/questions/12034357/does-alarm-manager-persist-even-after-reboot. All alarms are cleared after reboot. Your alarms are also removed when the user force closes your app. – GPuschka Jun 30 '16 at 07:46

0 Answers0