start Activity With Bundle and android.os.Handler - Android android.app

Android examples for android.app:Activity Start

Description

start Activity With Bundle and android.os.Handler

Demo Code

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class Main {

  public static void startActivityWithBundle(final Activity from, final Class<?> to, long delayMillis,
      final boolean finishSelf, final Bundle bundle) {
    new Handler().postDelayed(new Runnable() {

      @Override//  w w  w  .  ja  va  2s.c  o  m
      public void run() {
        Intent intent = new Intent(from, to);
        intent.putExtras(bundle);
        from.startActivity(intent);
        if (finishSelf == true) {
          from.finish();
        }
      }
    }, delayMillis);
  }

}

Related Tutorials