Search code examples
javaandroidalarmmanagerbackground-process

Clearing RAM stop showing Notifications


Using AlarmManager class i am able to schedule notification after 200 msec(For testing) code:

Intent alarmIntent = new Intent(this, AlarmReceiver.class);
pendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, 0);
manager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
int interval =200;
manager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),interval, pendingIntent);
public class AlarmReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context arg0, Intent arg1) {
   SetUpNotification.createNotification();

}}

But when I am Clearing RAM these notifications Stops and even if I close activity I can get these notifications, but not after clearing ram, I don't know what mistake am doing please help


Solution

  • Solution for MIUI 7.0 => Security => Autostart => select Apps that you want to run in background => Reboot After reboot your device should able to run your application services in background like other android devices do.

    MIUI 4.0 settings

    MIUI AutoStart Detailed Description