systemd start service on boot code example
Example 1: android start service on boot
<!-- Allows application to receive actions related to rebooting -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- Inside your <application> -->
<receiver
android:name="com.example.MyBroadcastReceiver"
android:exported="true"
android:enabled="true"
android:installLocation="internalOnly">
<intent-filter>
<!-- Handles cold reboot (power off/on) -->
<action android:name="android.intent.action.BOOT_COMPLETED" />
<!-- Handles quick restart -->
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
Example 2: start systemctl service
sudo systemctl start application.service