I have to log when the user installs my app, for that I have registered ACTION_PACKAGE_ADDED broadcast in manifest and created a receiver. but the receiver is not triggering after installing the app. I have tried with registering broadcast ACTION_PACKAGE_ADDED instead of PACKAGE_ADDED, and it works. I have read most of the SO questions regarding this and tried, but nothing works for me.I giving my code below
Manifest
<receiver android:name=".AppInstallReceiver">
<intent-filter android:priority="1">
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
Recevier
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) {
String packageName = intent.getDataString();
Log.i("Installed:", packageName + "package name of the program");
}
Log.d(TAG, "Action: " + intent.getAction());
Uri data = intent.getData();
Log.d(TAG, "The DATA: " + data);
}
Is there any problem with this code ?