Many apps provide recommendations to install other applications made by the developer or developer's partners. The recommendations are just links to the Play Store where the recommended app may be installed from.
I don't want to provide a recommendation for app X if:
Detecting if X is installed is easy, but I can't seem to find any API to read downloading/installing state from Google Play. Is there any way to detect if the user is in the process of installing app X?
Is there any way to detect if the user is in the process of installing app X?
The closest you'll get to this is by using a NotificationListenerService
.
From the docs:
A service that receives calls from the system when new notifications are posted or removed.
But considering this Service
was recently added in API level 18 and your use case, you might consider using a BroadcastReceiver
and listening for when android.intent.action.PACKAGE_ADDED
and android.intent.action.PACKAGE_REMOVED
are called. This way once an app is installed or removed, you can do what you want with the package name, like provide a link to the Play Store.
Here's an example:
BroadcastReceiver
public class PackageChangeReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent == null || intent.getData() == null) {
return;
}
final String packageName = intent.getData().getSchemeSpecificPart();
// Do something with the package name
}
}
In your AndroidManifest
<receiver android:name="your_path_to.PackageChangeReceiver" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With