如何从应用程序堆栈中隐藏我的启动器应用程序?
how to hide my launcher app from application stack?
我正在创建一个启动器应用程序,但每当我点击打开应用程序按钮时,它也会显示我的启动器应用程序。如何从应用程序堆栈中隐藏我的启动器。
我发现了一些隐藏在堆栈中的启动器,例如 Microsoft Launcher
Microsoft Launcher output
清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rayvatapps.officelauncher">
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.HARDWARE_TEST" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- <uses-feature
android:name="android.software.leanback"
android:required="true" />-->
<application
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:largeHeap="true"
android:roundIcon="@drawable/logo_bg"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="com.rayvatapps.officelauncher.MainActivity"
android:launchMode="singleTask"
android:stateNotNeeded="true"
android:theme="@style/AppTheme.Wallpaper" />
<activity
android:name="com.rayvatapps.officelauncher.AppListActivity"
android:theme="@style/AppTheme.Wallpaper" />
<activity
android:name="com.rayvatapps.officelauncher.PinActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.Wallpaper">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<!--<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>-->
</intent-filter>
</activity>
<activity
android:name="com.rayvatapps.officelauncher.SettingActivity"
android:label="Settings" />
</application>
</manifest>
我怎样才能像这个应用一样隐藏我的启动器应用。
请给我建议,我们将不胜感激。
将 android:excludeFromRecents="true"
添加到清单中的 Activity(所有活动?)。这将从 recent/running 应用菜单
中删除 activity
试试这个代码,
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, "your class name");
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
以上代码写入启动器Activity
我正在创建一个启动器应用程序,但每当我点击打开应用程序按钮时,它也会显示我的启动器应用程序。如何从应用程序堆栈中隐藏我的启动器。
我发现了一些隐藏在堆栈中的启动器,例如 Microsoft Launcher
Microsoft Launcher output
清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rayvatapps.officelauncher">
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.HARDWARE_TEST" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- <uses-feature
android:name="android.software.leanback"
android:required="true" />-->
<application
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:largeHeap="true"
android:roundIcon="@drawable/logo_bg"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="com.rayvatapps.officelauncher.MainActivity"
android:launchMode="singleTask"
android:stateNotNeeded="true"
android:theme="@style/AppTheme.Wallpaper" />
<activity
android:name="com.rayvatapps.officelauncher.AppListActivity"
android:theme="@style/AppTheme.Wallpaper" />
<activity
android:name="com.rayvatapps.officelauncher.PinActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.Wallpaper">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<!--<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>-->
</intent-filter>
</activity>
<activity
android:name="com.rayvatapps.officelauncher.SettingActivity"
android:label="Settings" />
</application>
</manifest>
我怎样才能像这个应用一样隐藏我的启动器应用。 请给我建议,我们将不胜感激。
将 android:excludeFromRecents="true"
添加到清单中的 Activity(所有活动?)。这将从 recent/running 应用菜单
试试这个代码,
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, "your class name");
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
以上代码写入启动器Activity