Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;

public class Main {
    public static void goTo(Activity aty, Class clazz) {
        goTo(aty, clazz, false);
    }

    public static void goTo(Fragment fragment, Class clazz) {
        goTo(fragment.getActivity(), clazz, false);
    }

    public static void goTo(Activity aty, Class clazz, boolean isFinish) {
        goTo(aty, clazz, null, isFinish);
    }

    public static void goTo(Activity aty, Class clazz, Bundle bundle) {
        goTo(aty, clazz, bundle, false);
    }

    public static void goTo(Fragment fragment, Class clazz, boolean isFinish) {
        goTo(fragment.getActivity(), clazz, null, isFinish);
    }

    public static void goTo(Fragment fragment, Class clazz, Bundle bundle) {
        goTo(fragment.getActivity(), clazz, bundle, false);
    }

    public static void goTo(Activity aty, Class clazz, Bundle bundle, boolean isFinish) {
        Intent intent = new Intent(aty, clazz);
        if (bundle != null) {
            intent.putExtras(bundle);
        }
        aty.startActivity(intent);
        if (isFinish) {
            aty.finish();
        }
    }
}