一、manifest的配置
<receiver android:name=".AppReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
二、receiver中的判断
public class AppReceiver extends BroadcastReceiver
{
private static final int PACKAGE_NAME_START_INDEX = 8;
@Override
public void onReceive(Context context, Intent intent)
{
if(intent == null)
{
return;
} if(intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED))
{
String data = intent.getDataString(); if(data == null || data.length() <= PACKAGE_NAME_START_INDEX)
{
return;
} String packageName = data.substring(PACKAGE_NAME_START_INDEX); if(packageName.equals(AppActivity.PACKAGE_NAME) )
{
//todo
}
} } }