Search code examples
androidbroadcastreceiveradb

Is their any way to differentiate package installation from adb command and from playstore?


I have used Intent-filter PACKAGE_NAME to capture the package name of the newly installed app from Playstore or by adb command.Can anyone suggest me how to differentiate between package installation from playstore and from adb.

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);

This will work both for adb installation and installation from playstore. I need it to be specific to playstore.


Solution

  • You can use packageManager.getInstallerPackageName

    And com.android.vending is the package of Play Store