Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Intent;
import android.net.Uri;

import java.io.File;

public class Main {

    public static Intent getWordFileIntent(String param) {
        return getIntentByType(param, "application/msword");
    }

    private static Intent getIntentByType(String param, String type) {
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.addCategory("android.intent.category.DEFAULT");
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Uri uri = Uri.fromFile(new File(param));
        intent.setDataAndType(uri, type);
        return intent;
    }
}