check App Not Sideloaded - Android App

Android examples for App:App Running

Description

check App Not Sideloaded

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 {
    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 boolean checkNotSideloaded(Context context) {
        List<String> mergedList = new ArrayList<>();
        mergedList.addAll(playstoreList);
        mergedList.addAll(amazonList);//from w  w w. j a  v a  2 s.com

        final String installer = context.getPackageManager()
                .getInstallerPackageName(context.getPackageName());

        return installer != null && mergedList.contains(installer);
    }
}

Related Tutorials