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.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;

public class Main {
    public static boolean isCanInstallToExternal(String apkPath, Context context) {
        boolean canExternal = true;
        try {
            PackageInfo info = context.getPackageManager().getPackageArchiveInfo(apkPath,
                    PackageManager.GET_META_DATA);

            Bundle bundle = info.applicationInfo.metaData;

            if (bundle != null) {
                String value = bundle.getString("kyx_external");
                if (value != null && value.equals("no")) {
                    canExternal = false;
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        return canExternal;
    }
}