Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

public class Main {
    public static void jumpToActivity(Context context, Intent datatIntent) {
        context.startActivity(datatIntent);
    }

    public static void jumpToActivity(Context context, Class<? extends Activity> targetClass) {
        Intent datatIntent = new Intent(context, targetClass);
        context.startActivity(datatIntent);
    }

    public static void jumpToActivity(Context context, Class<? extends Activity> targetClass, String... datas) {
        Intent datatIntent = new Intent(context, targetClass);
        if (datas != null) {
            for (int i = 0; i < datas.length; ++i) {
                datatIntent.putExtra("data" + i, datas[i]);
            }
        }

        context.startActivity(datatIntent);
    }

    public static void jumpToActivity(Context context, ComponentName componentName) {
        Intent mIntent = new Intent();
        mIntent.addFlags(268435456);
        mIntent.setComponent(componentName);
        mIntent.setAction("android.intent.action.VIEW");
        context.startActivity(mIntent);
    }

    public static void jumpToActivity(Context context, ComponentName componentName, String... datas) {
        Intent mIntent = new Intent();
        mIntent.addFlags(268435456);
        mIntent.setComponent(componentName);
        mIntent.setAction("android.intent.action.VIEW");
        if (datas != null) {
            for (int i = 0; i < datas.length; ++i) {
                mIntent.putExtra("data" + i, datas[i]);
            }
        }

        context.startActivity(mIntent);
    }
}