Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;
import android.content.Intent;

public class Main {
    /**
     * Launch the specified application
     *
     * @param context
     *            application context
     * @param packageName
     *            package name of the application to launch
     */
    public static boolean launchApp(Context context, String packageName) {
        if (!context.getPackageName().equals(packageName)) // Launch if it is
        // different app
        {
            final Intent LaunchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName);
            context.startActivity(LaunchIntent);
            return true;
        }
        return false;
    }
}