添加开机启动功能。
This commit is contained in:
		| @@ -1,8 +1,8 @@ | ||||
| #Created by .winboll/winboll_app_build.gradle | ||||
| #Thu Jul 24 15:25:52 HKT 2025 | ||||
| #Mon Jul 28 03:33:08 GMT 2025 | ||||
| stageCount=3 | ||||
| libraryProject= | ||||
| baseVersion=15.1 | ||||
| publishVersion=15.1.2 | ||||
| buildCount=0 | ||||
| buildCount=3 | ||||
| baseBetaVersion=15.1.3 | ||||
|   | ||||
| @@ -3,6 +3,9 @@ | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     package="cc.winboll.studio.timestamp"> | ||||
|  | ||||
|     <!-- 开机启动 --> | ||||
|     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> | ||||
|  | ||||
|     <!-- 运行前台服务 --> | ||||
|     <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> | ||||
|  | ||||
| @@ -45,6 +48,20 @@ | ||||
|  | ||||
|         <service android:name=".AssistantService"/> | ||||
|  | ||||
|         <receiver | ||||
|             android:name=".receivers.MainReceiver" | ||||
|             android:enabled="true" | ||||
|             android:exported="false" | ||||
|             android:directBootAware="true"> | ||||
|  | ||||
|             <intent-filter> | ||||
|  | ||||
|                 <action android:name="android.intent.action.BOOT_COMPLETED"/> | ||||
|  | ||||
|             </intent-filter> | ||||
|  | ||||
|         </receiver> | ||||
|  | ||||
|     </application> | ||||
|  | ||||
| </manifest> | ||||
|   | ||||
| @@ -0,0 +1,40 @@ | ||||
| package cc.winboll.studio.timestamp.receivers; | ||||
|  | ||||
| import android.content.BroadcastReceiver; | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.timestamp.MainService; | ||||
| import cc.winboll.studio.timestamp.models.AppConfigsModel; | ||||
| import cc.winboll.studio.timestamp.utils.AppConfigsUtil; | ||||
|  | ||||
| /** | ||||
|  * @Author ZhanGSKen&豆包大模型<zhangsken@188.com> | ||||
|  * @Date 2025/07/28 11:15 | ||||
|  * @Describe MainReceiver | ||||
|  */ | ||||
| public class MainReceiver extends BroadcastReceiver { | ||||
|  | ||||
|     public static final String TAG = "MainReceiver"; | ||||
|  | ||||
|     static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; | ||||
|  | ||||
|     AppConfigsUtil mAppConfigsUtil; | ||||
|  | ||||
|     @Override | ||||
|     public void onReceive(Context context, Intent intent) { | ||||
|         String szAction = intent.getAction(); | ||||
|         if (szAction.equals(ACTION_BOOT_COMPLETED)) { | ||||
|             AppConfigsModel appConfigs = AppConfigsUtil.getInstance(context).loadAppConfigs(); | ||||
| 			boolean isEnable = appConfigs.isEnableService(); | ||||
| 			AppConfigsUtil.getInstance(context).saveAppConfigs(); | ||||
|  | ||||
| 			Intent intentMainService = new Intent(context, MainService.class); | ||||
| 			if (isEnable) { | ||||
| 				context.startService(intentMainService); | ||||
| 			} | ||||
| 			LogUtils.i(TAG, "System Boot And Start ManagerService Completed!"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 ZhanGSKen
					ZhanGSKen