This is a question about starting the service when installing/updating the Android app.

Asked 2 years ago, Updated 2 years ago, 26 views

I'm asking you this question because there's a blockage during Android development.

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_ADDED" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_CHANGED" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_INSTALL" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_REPLACED" />

  <receiver
        android:name=".BCReceiver"
        android:enabled="false"
        android:exported="false">
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.ACTION_SHUTDOWN" />

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

I'm testing to add receiver and delete app installation as above It works well when it comes to booting, but the app installation update doesn't work I can't find the answer even if I look everywhere, so I leave a question like this. The Android version is 5.1.1 (SDK 22) and upon receipt of the broadcast receiver's onReceive, If you leave a log, events such as shutdown boot will occur, but the rest will not occur. I need your help.

android

2022-09-22 21:14

1 Answers

For no particular reason, set the enabled, exported property of the broadcast receiver to true. If exported is false, you will not be able to receive messages from outside the app. Please change the two settings to true and test them.

For package installation, deletion, and update, it is helpful to look at the launch source code in AOSP. Please refer to the link below.


2022-09-22 21:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.