@Override
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case MSG_SPAM:
       {
         boolean fg = msg.arg1 != 0;
         Intent intent = new Intent(ActivityTestMain.this, SpamActivity.class);
         Bundle options = null;
         if (fg) {
           ActivityOptions opts = ActivityOptions.makeTaskLaunchBehind();
           options = opts.toBundle();
         }
         startActivity(intent, options);
         scheduleSpam(!fg);
       }
       break;
     case MSG_SPAM_ALARM:
       {
         long when = SystemClock.elapsedRealtime();
         Intent intent = new Intent(ActivityTestMain.this, AlarmSpamReceiver.class);
         intent.setAction("com.example.SPAM_ALARM=" + when);
         PendingIntent pi = PendingIntent.getBroadcast(ActivityTestMain.this, 0, intent, 0);
         mAlarm.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME, when + (30 * 1000), pi);
         scheduleSpamAlarm(30 * 1000);
       }
       break;
   }
   super.handleMessage(msg);
 }
 @Override
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case MSG_SPAM:
       {
         boolean fg = msg.arg1 != 0;
         Intent intent = new Intent(ActivityTestMain.this, SpamActivity.class);
         Bundle options = null;
         if (fg) {
           ActivityOptions opts = ActivityOptions.makeTaskLaunchBehind();
           options = opts.toBundle();
         }
         startActivity(intent, options);
         scheduleSpam(!fg);
       }
       break;
   }
   super.handleMessage(msg);
 }