关于uniapp 的开机自启动解决方案,桌面应用

最近开发app遇到一个问题,软件需要再设备开机后进行自动启动,但是由于技术栈使用的uni-app,就卡在了原生插件的运用,试了很多插件,都不太行,最后找到了一个曲线救国的方案,特此进行记录。

Android 开机自启动方案
在HBuilderX中,在根目录右键菜单 “新建” -> “自定义文件”

在这里插入图片描述
输入文件名称 AndroidManifest.xml(注意大小写敏感),点击 “创建” 按钮新建文件

然后,填入Android原生的自启动配置(注意替换为你的名包)

<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="33" android:compileSdkVersionCodename="13" package="你的包名" platformBuildVersionCode="33" platformBuildVersionName="13">
	<application android:allowBackup="false" android:allowClearUserData="true" android:appComponentFactory="androidx.core.app.CoreComponentFactory" android:debuggable="false" android:extractNativeLibs="true" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:largeHeap="true" android:name="io.dcloud.application.DCloudApplication" android:supportsRtl="true" android:usesCleartextTraffic="true">
        <activity android:configChanges="fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize" android:exported="true" android:hardwareAccelerated="true" android:label="@string/app_name" android:name="io.dcloud.PandoraEntry" android:screenOrientation="user" android:theme="@style/DCloudTranslucentTheme" android:windowSoftInputMode="adjustResize">
            <intent-filter>
				<action android:name="android.intent.action.MAIN"/>
				<category android:name="android.intent.category.LAUNCHER"/>
				<category android:name="android.intent.category.HOME"/>
				<category android:name="android.intent.category.DEFAULT"/>
			</intent-filter>
			<intent-filter>
				<action android:name="android.intent.action.VIEW"/>
				<category android:name="android.intent.category.DEFAULT"/>
				<category android:name="android.intent.category.BROWSABLE"/>
			</intent-filter>
		</activity>	
    </application>
</manifest>

最后在HBuilderX中提交云打包。

原理文档:Android原生应用清单文件和资源 | uni-app官网

转自文章:uniapp android 开机自启动解决方案

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值