Andy Jadeja
Andy Jadeja

Reputation: 11

How to restrict users to use our application installing outside of play store?

I want my application to be installed only from play store, there are so many sites people download the app and use them. I want to restrict them.

if anyone downloaded from other site, they will can't use the app and popup coming.. Like please download the app from play store.

Please explain step by step, I am newbie here....

Thanks

Upvotes: 0

Views: 511

Answers (1)

Kamal Nayan
Kamal Nayan

Reputation: 1718

As answered here


boolean verifyInstallerId(Context context) {
    // A list with valid installers package name
    List<String> validInstallers = new ArrayList<>(Arrays.asList("com.android.vending", "com.google.android.feedback"));

    // The package name of the app that has installed your app
    final String installer = context.getPackageManager().getInstallerPackageName(context.getPackageName());

    // true if your app has been downloaded from Play Store 
    return installer != null && validInstallers.contains(installer);
}

You can check either your app is installed from Play Store or not and accordingly show them the pop-up.

Upvotes: 1

Related Questions