1
@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");
    }
}

//我的清单文件:

<receiver android:name="com.example.anotherbroadcastreceiverexample.MyReceiver" android:enabled="true">
            <intent-filter><action android:name="android.intent.action.PACKAGE_INSTALL"/></intent-filter>

    </receiver>
4

1 回答 1

0

您能否尝试通过以下方式修改您的清单:

<intent-filter>
    <action android:name="android.intent.action.PACKAGE_INSTALL" />
    <action android:name="android.intent.action.PACKAGE_ADDED" />
    <data android:scheme="package"/>
</intent-filter>

更新:

检查不是 PACKAGE_INSTALL 检查操作 PACKAGE_ADDED。

于 2013-02-28T09:45:28.537 回答