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;

import android.net.Uri;
import android.os.Environment;

public class Main {
    private static final String FILE_DIR = "/temp";

    public static void startInstall(final Context context, String fileName) {
        Intent intent = new Intent();
        intent.setAction(android.content.Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse("file://" + getSdcardFileName(fileName)),
                "application/vnd.android.package-archive");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }

    public static String getSdcardFileName(String fileName) {
        return Environment.getExternalStorageDirectory() + FILE_DIR + "/" + fileName;
    }
}