问题
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Toast.makeText(context, "Package Received", Toast.LENGTH_SHORT).show();
Log.d("Package Installing", "Package Installing");
String action=intent.getAction();
if(action.equals(intent.ACTION_PACKAGE_INSTALL))
{
Toast.makeText(context, "Package Added", Toast.LENGTH_SHORT).show();
Log.d("Package INstalling", "Package Installed");
}
}
//My Manifest File:
<receiver android:name="com.example.anotherbroadcastreceiverexample.MyReceiver" android:enabled="true">
<intent-filter><action android:name="android.intent.action.PACKAGE_INSTALL"/></intent-filter>
</receiver>
回答1:
Could you try to modify your Manifest in the following way:
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<data android:scheme="package"/>
</intent-filter>
UPDATE:
Check not PACKAGE_INSTALL check action PACKAGE_ADDED.
来源:https://stackoverflow.com/questions/15132023/broadcastreceiver-for-package-install-not-working