Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static void startActivity(Context context, Intent intent) {
        if (context instanceof Activity) {
            startActivity((Activity) context, intent, -1);
        } else {
            context.startActivity(intent);
        }
    }

    public static void startActivity(Activity a, Intent intent, int requestCode) {
        if (requestCode >= 0) {
            a.startActivityForResult(intent, requestCode);
        } else {
            a.startActivity(intent);
        }
    }

    public static void startActivity(Context context, Intent intent, Bundle options) {
        ActivityCompat.startActivity((Activity) context, intent, options);
    }
}