I have seen article this . Then I try to make a example to catch event when I installed app
This is my code `
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppInstalled appInstalled = new AppInstalled();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
intentFilter.addDataScheme("package");
registerReceiver(appInstalled, intentFilter);
}
private class AppInstalled extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(SplashActivity.this, "Application Installed", Toast.LENGTH_SHORT).show();
}
}`
But it's never show message . Please give me some advice
You have to add your receiver into AndroidManifest.xml file under tag. Please check it.
register you receiver in manifest file
<receiver android:name=".AppInstalled">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<data android:scheme="package"/>
</intent-filter>
</receiver>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.