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.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

import android.graphics.drawable.Drawable;

import android.net.Uri;

import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;

import java.util.List;

public class Main {
    public static Drawable getDrawableForMimetype(Uri uri, String str, Context context) {
        if (str == null) {
            return null;
        }
        PackageManager packageManager = context.getPackageManager();
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setDataAndType(uri, str);
        List queryIntentActivities = packageManager.queryIntentActivities(intent,
                AccessibilityNodeInfoCompat.ACTION_CUT);
        return (queryIntentActivities == null || queryIntentActivities.size() <= 0) ? null
                : ((ResolveInfo) queryIntentActivities.get(queryIntentActivities.size() - 1))
                        .loadIcon(packageManager);
    }
}