move To Activity - Android android.app

Android examples for android.app:Activity Navigation

Description

move To Activity

Demo Code

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

public class Main {

  public static void moveToActivity(Activity activity, Class targetClass, Bundle bundle) {

    if (activity == null || activity.isFinishing()) {
      return;/*from   ww  w . j a  va2  s.c o  m*/
    }
    Intent intent = new Intent(activity, targetClass);
    if (bundle != null) {
      intent.putExtras(bundle);
    }
    activity.startActivity(intent);
  }

  public static void moveToActivity(Activity activity, Class targetClass) {
    moveToActivity(activity, targetClass, null);
  }

}

Related Tutorials