Edit: Managed to solve it. Created a new project, cleared app data before uninstalling it, re-installed it, and it magically worked. Thanks for the help.
I'm trying to detect when an app is installed, but I'm not quite sure where I am going wrong. I've checked several questions on here, but I just can't seem to figure it out. I'm pretty new to android, so I may have missed something obvious. Here is the test case of what I have.
I installed it to my phone, and the process and service is shown as running in the settings. Then, I download an app from the play store, check the logcat, and there is nothing from the app.
Any help on where I'm going wrong? Thanks.
Edit:
After playing with it some more, I have some new example test code. When a new package is installed, the onReceive method doesn't fire. However, as I was testing things out, I added a constructor to the BroadcastReceiver class, and the constructor fires everytime a package is installed. So, it seems to be receiving the intent, but the log inside the onReceive never seems to print out. Any ideas?
public class InstallReceiver extends BroadcastReceiver {
public InstallReceiver()
{
//This log will display in the logcat
Log.d("InstallReceiver", "InstallReceiver constructor called.");
}
@Override
public void onReceive(Context context, Intent intent) {
//This log never displays if the constructor is in or commented out
Log.d("InstallReceiver", "Install detected.");
}
}
<receiver android:name=".InstallReceiver">
<intent-filter >
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>