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.content.Intent;
import android.net.Uri;

import android.support.annotation.NonNull;

import android.text.TextUtils;
import java.net.URLConnection;

public class Main {
    @NonNull
    public static Intent openContent(@NonNull Uri uri) {
        final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        final String mime = URLConnection.guessContentTypeFromName(uri.toString());
        if (!TextUtils.isEmpty(mime)) {
            intent.setType(mime);
        }
        return intent;
    }
}