Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

public class Main {
    private static final String ANDROID_INSTALLER = "com.android.vending";

    public static boolean isInstalledFromGooglePlay(Context context) {
        return isPackageInstaller(context, ANDROID_INSTALLER);
    }

    public static boolean isPackageInstaller(Context appContext, String installer) {
        String installerPackageName = appContext.getPackageManager()
                .getInstallerPackageName(appContext.getPackageName());
        return installerPackageName != null && installerPackageName.equals(installer);
    }
}