Listening for package change events of certain pac

2019-07-06 03:16发布

I have a pro key application package for my application, and I would like to set up a BroadcastReceiver to receive intents when the pro key package is added or updated. Here's my code:

<receiver android:name=".Receiver">
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_ADDED" />
        <action android:name="android.intent.action.PACKAGE_CHANGED" />
        <data android:scheme="package" android:path="com.test.key"/>
    </intent-filter>
</receiver>

The code starts up the receiver on every app I install or update the com.test.key app, but it fires for every other apps as well. How can I listen for package updates for com.test.key only?

I know how to do it in the Receiver.java (intent.getData().getSchemeSpecificPart()). I'm looking for a way to do the filtering in the Android Manifest, so the broadcast doesn't get fired every time user installs an app.

0条回答
登录 后发表回答