Qt for android 开机自启动、开机黑屏处理

本文介绍了如何使用Qt for Android实现应用的开机自启动以及解决开机黑屏问题。首先,通过创建AndroidManifest.xml并添加相应配置实现开机自启动。接着,针对开机黑屏,通过设置启动图片和创建Styles.xml文件定义自定义主题,以展示一张logo页面运行,从而消除黑屏现象。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1:开机自启动

1.1 创建AndroidManifest.xml

项目->构建->Build Android APK->Use Gradle->Create Templates->打钩Copy the Gra...->完成

1.2 添加内容

	<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>


1.3 编译运行即可开机运行。


2:开机黑屏处理

<一>一张logo页面运行

2.1 在工程目录下添加启动图片 Android/res/drawable-hdpi/splash.png 

2.2  在工程目录下添加一个android/res/values/Styles.xml文件

	<resources>  
	<style name="Theme.AppStartLoad" parent="android:Theme">  
    		<item name="android:windowBackground">@drawable/splash</item>  
    		<item name="android:windowNoTitle">true</item>  
	</style>  
	<style name="Theme.AppStartLoadTranslucent" parent="android:Theme">  
    		<item name="android:windowIsTranslucent">true</item>  
    		<item name="android:windowNoTitle">true</item>  
	</style>  
	</resources>


2.3  然后在AndroidManifest.xml中的activity中加上

	android:theme="@style/Theme.AppStartLoad"

2.4 在AndroidManifest.xml中的application中加上
	android:theme = "@style/Theme.AppStartLoadTranslucent"


2.5 然后添加下面的内容,不然当主界面内容比较多时,依旧会出现黑屏问题。

	<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash"/> 
<二>闪烁运行

2.1 新建styles.xml,新建一个MyAppTheme主题,写入内容:

	<?xml version='1.0' encoding='utf-8'?>  
	<resources>  
    		<style name="MyAppTheme">  
        		<item name="android:windowDisablePreview">true</item>  
        		<item name="android:windowBackground">@null</item>  
        		<item name="android:windowContentOverlay">@null</item>  
        		<item name="android:windowIsTranslucent">false</item>  
        		<item name="android:windowAnimationStyle">@null</item>  
        		<!-- 
        		<item name="android:windowBackground">@drawable/splash</item> 
        		-->  
    		</style>  
	</resources> 


2.2 在AndroidManifest.xml文件,选择「XML Source」显示源码,在application节点上添加「android:theme="@style/MyAppTheme"」,保存。

	<application android:hardwareAccelerated="true"  
     		android:name="org.qtproject.qt5.android.bindings.QtApplication"  
     		android:label="quitDemo"  
     		android:theme="@style/MyAppTheme">

备注:网上搜到的可用方法,暂时没研究原理,懂得请留言,指导指导!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值