基本上,问题就在标题中。
- 此选项有什么作用?
- 它会影响什么?
- 它与以下有什么关系 Activity 生命周期和/或服务生命周期?
示例:
<?xml version="1.0"?>
<manifest package="org.example.test" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.1" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/app_name" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.StartActivity" android:label="@string/app_name" android:screenOrientation="sensorLandscape" android:launchMode="singleTop" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="true"/>
</activity>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
</manifest>
它在 Android 的 QT 应用程序中使用,但我认为它与 QT 无关,因为它在 list 中。我错了吗?
最佳答案
由于这个选项实际上与我之前认为的 Android API 无关,因此我开始深入研究 QT 源代码,这意味着什么。
设置此选项将导出QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED
环境变量,该变量将由QT native 代码检查并停止事件调度程序(此后不会调用QCoreApplication::processEvents
) ) 当主 Activity 通过 onStop(
) 和 onPause()
方法停止或暂停时,应用程序的 QT 部分。这就是“卡住”事件循环的含义。
我不知道应该注意的所有注意事项,但我一发现就会更新我的答案。
关于android - AndroidManifest.xml中的 "android.app.background_running"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35798022/