check App APK Install Location - Android App

Android examples for App:App Install

Description

check App APK Install Location

Demo Code


//package com.java2s;
import android.content.Context;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
    public static final int GOOGLE_PLAY = 1;
    public static final int AMAZON = 2;
    public static final int SIDELOAD = 0;
    private static List<String> playstoreList = new ArrayList<>(
            Arrays.asList("com.android.vending",
                    "com.google.android.feedback"));
    private static List<String> amazonList = new ArrayList<>(
            Collections.singletonList("com.amazon.venezia"));

    public static int checkInstallLocation(Context context) {
        final String installer = context.getPackageManager()
                .getInstallerPackageName(context.getPackageName());
        if (installer == null)
            return SIDELOAD;
        if (playstoreList.contains(installer))
            return GOOGLE_PLAY;
        if (amazonList.contains(installer))
            return AMAZON;
        return SIDELOAD;
    }/*from   w  w w.  j a va 2s.c  om*/
}

Related Tutorials