Hi everyone, how we can find my app installed from Indus appstore or not. It is same like app installed from play store.
Please help me
Hey pk,
Could you explain yourself better, do you want to know if your app was installed from one store rather than another?
If so, you could simply name the version differently,the one uploaded to the PlayStore you call ps-1.0.2, for Indus i-1.0.2
Yes, Indus appstore is a alternative of play store in India. How to find my app installed from Indus appstore?
Sorry, I later edited the message.
I asked Gemini for you and below is the answer.
You could write an extension and prepare a new method, which returns the installer package name
Taifun
To programmatically find the app store from which an Android app was installed, you can use the PackageManager class. There are two primary methods you’ll want to use depending on the Android API level.
Using getInstallerPackageName()
For Android versions below API level 30 (Android 11), you can use the getInstallerPackageName() method. This method returns the package name of the app that initiated the installation.
- Google Play Store: The method returns “com.android.vending”.
- Amazon Appstore: The method returns “com.amazon.venezia”.
- Sideloaded (installed from an APK file): This typically returns null or the package name of the system’s package installer. This can be inconsistent.
Here’s a code snippet showing how to use it:
String installerPackageName = context.getPackageManager().getInstallerPackageName(context.getPackageName());
if ("com.android.vending".equals(installerPackageName)) {
// App was installed from Google Play Store
} else if ("com.amazon.venezia".equals(installerPackageName)) {
// App was installed from Amazon Appstore
} else {
// App was sideloaded or from another store
}
Using getInstallSourceInfo()
For Android versions API level 30 (Android 11) and higher, getInstallerPackageName() is deprecated. You should use the getInstallSourceInfo() method, which returns an InstallSourceInfo object containing richer installation details. The installingPackageName field of this object provides the same information as the old method but is the new, recommended approach.
Here’s the updated code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
try {
InstallSourceInfo installSourceInfo = context.getPackageManager().getInstallSourceInfo(context.getPackageName());
String installingPackageName = installSourceInfo.getInstallingPackageName();
if ("com.android.vending".equals(installingPackageName)) {
// App was installed from Google Play Store
} else if ("com.amazon.venezia".equals(installingPackageName)) {
// App was installed from Amazon Appstore
} else {
// App was sideloaded or from another store
}
} catch (PackageManager.NameNotFoundException e) {
// Handle the exception
}
} else {
// Use the getInstallerPackageName() method for older versions
String installerPackageName = context.getPackageManager().getInstallerPackageName(context.getPackageName());
// ... rest of the code for older versions
}
Important Considerations ![]()
- Installer Package Names: You’ll need to know the specific package names for the app stores you want to check for. The list above covers the major ones, but others will have different package names.
- Sideloading Ambiguity: When an app is installed directly from an APK (sideloading), the installer package name might be null or a generic system package name, making it difficult to distinguish from an app installed by an unknown app store.
- API Availability: Ensure you handle the different API levels correctly to avoid crashes on older or newer devices. The code snippets above demonstrate a good practice for this.
But how implement this code. I don’t know aix devlopment.
Here installer package name - com.indus.appstore
So what will happen after getting these package names, functions like close the app? I like learning, maybe i can try compiling small aix to try
What your aim, allow only from Play store?
This extension should do what you’re asking, but I don’t know if it uses getInstallSourceInfo().
more information about how to create an extension see the App Inventor Extensions document
however that will be more advanced and will require some Java skills…
I move this thread into category Marketplace for you. Probably soneone is interested to write it for free for you. I also could do it for a small fee. If you are interested in the latter, just send me a PM
EDIT: this PkgUtils : An extension to work with Packages seems to already have the method you are looking for
Taifun
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
