将应用设置为家庭启动另一个实例

问题描述 投票:0回答:1

我想将我的应用设置为启动器(家庭应用),但是我无法正确执行某些行为。首先,我打开应用程序并返回主屏幕,使其停留在后台。然后,当我在设置主页应用程序中进行设置以进行挖掘时,它将创建新实例。另外,当我返回到默认启动器应用程序的设置时,似乎没有在正在运行的应用程序列表中显示。我不确定如何正确使用它,我尝试了不同的启动模式,但似乎无济于事。

这是我的清单文件

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="xxx" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:keepScreenOn="true" android:label="@string/activity_name" android:launchMode="singleTop" android:name="jk.cordova.plugin.kiosk.KioskActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.HOME" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.darryncampbell.cordova.plugin.intent.ACTION" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <receiver android:name="jk.cordova.plugin.kiosk.MyPackageReplacedEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>
        <provider android:authorities="${applicationId}.darryncampbell.cordova.plugin.intent.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="com.darryncampbell.cordova.plugin.intent.CordovaPluginIntentFileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" />
        </provider>
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
    <uses-permission android:name="android.permission.REORDER_TASKS" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
</manifest>
java android ionic-framework android-activity kiosk-mode
1个回答
0
投票

您已将launchMode设置为singleTop。这意味着,只有一个实例位于堆栈的顶部,您才能拥有它。

文档

也可以创建“ singleTop”活动的新实例来处理新的意图。但是,如果目标任务在其堆栈的顶部已经具有该活动的现有实例,则该实例将收到新的意图(在onNewIntent()调用中);没有创建新实例。在其他情况下(例如,如果“ singleTop”活动的现有实例在目标任务中,但不在堆栈的顶部,或者如果它在堆栈的顶部,但不在目标任务的顶部),则新实例将被创建并压入堆栈。

您正在尝试的内容:

[首先,我打开应用程序,然后返回主屏幕,使其停留在后台。

我不认为启动器之间的最新功能可以满足您的期望。

然后,当我在设置主页应用程序中进行设置以进行挖掘时,它会创建新实例。

是的,因为这是启动器,它会启动一个新的过程。

此外,当我返回默认启动器应用程序的设置时,似乎也不会在正在运行的应用程序列表中显示。

启动器活动未在最近的应用程序中显示。

© www.soinside.com 2019 - 2024. All rights reserved.