If you do not start after installing APP, how to boot the Activity or Service? of APP

We know that the method of enabling startup in Android registers a static broadcast to listen to the broadcast that has been booted, and then after receiving the boot broadcast, the method of starting Activity or Service, is as follows:
first, create a new broadcast listener to listen to the broadcast that has been booted

public class BootCompletedReceiver extends BroadcastReceiver {

    private static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
 
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(action_boot)){
            Intent intent=new Intent(context,MainActivity.class);
            ootStartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        }
    }
}

then, statically register the broadcast with AndroidManifest.xml

<receiver android:name=".BootCompletedReceiver">
        <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <category android:name="android.intent.category.HOME" />
        </intent-filter>
</receiver>

finally, apply for permission in AndroidManifest.xml

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

it is possible to enable and launch APP, through the above methods. However, there is a problem with this method. The above methods must manually run APP after installing APP before APP can receive android.intent.action.BOOT_COMPLETED broadcasts.

if APP has no Activity, only Service, or cannot be run manually after installation, and the Service or Activity, of this APP cannot be started through other APP, how can it be started after installation? What methods does PS: have on the basis that it can modify the Android system code?

Apr.02,2021

there are several possible reasons why APP cannot receive BOOT_COMPLETED broadcasts:

  1. BOOT_COMPLETED corresponding to action and uses-permission are not added together
  2. The
  3. application is installed in the sd card, and the application installed in the sd card will not receive BOOT_COMPLETED broadcast
  4. .
  5. the system opens Fast Boot mode, in which the system starts up and does not send BOOT_COMPLETED broadcast
  6. The
  7. application has not been restarted after installation, in which case the application does not receive any broadcasts, including BOOT_COMPLETED , ACTION_PACKAGE_ADDED , CONNECTIVITY_ACTION , and so on.
After

Android3.1, in order to strengthen the security control, the system is in the stopped state after the application is installed or after being forcibly closed in the application management, and no broadcast can be received in this state, unless the broadcast is marked with FLAG_INCLUDE_STOPPED_PACKAGES , and all system broadcasts are FLAG_EXCLUDE_STOPPED_PACKAGES by default, so it is impossible to start self-starting through the system broadcast.
so after Android3.1:

  1. the application cannot start itself after installation
  2. A program without ui must be activated by other applications, such as its Activity, Service, and Content Provider, which are called by other applications.

however, there is an exception that the application starts automatically under adb push you.apk / system/app/ and is not in the stopped state.

http://developer.android.com/.
http://commonsware.com/blog/2.

that is, the solution is to push the APK to the / system/app directory, or when you package the system, place the APK in / system/app to package

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e36e01-4311a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e36e01-4311a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?