From 8c6b6c5e914db27a8b45c3fc54f5c939c91ef128 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Sun, 10 Apr 2022 17:28:55 +0200 Subject: [PATCH] Launch app main activities with the correct action and category Fix #15 --- .../mm20/launcher2/search/data/LauncherApp.kt | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/applications/src/main/java/de/mm20/launcher2/search/data/LauncherApp.kt b/applications/src/main/java/de/mm20/launcher2/search/data/LauncherApp.kt index 1a5a8951..bc157cd1 100644 --- a/applications/src/main/java/de/mm20/launcher2/search/data/LauncherApp.kt +++ b/applications/src/main/java/de/mm20/launcher2/search/data/LauncherApp.kt @@ -3,11 +3,9 @@ package de.mm20.launcher2.search.data import android.content.ActivityNotFoundException import android.content.ComponentName import android.content.Context -import android.content.Intent import android.content.pm.LauncherActivityInfo import android.content.pm.LauncherApps import android.content.pm.PackageManager -import android.content.pm.ShortcutInfo import android.graphics.drawable.AdaptiveIconDrawable import android.os.Bundle import android.os.Process @@ -15,7 +13,6 @@ import android.os.UserHandle import androidx.core.content.getSystemService import de.mm20.launcher2.icons.LauncherIcon import de.mm20.launcher2.ktx.getSerialNumber -import de.mm20.launcher2.ktx.tryStartActivity import de.mm20.launcher2.preferences.Settings.IconSettings.LegacyIconBackground import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -77,24 +74,17 @@ class LauncherApp( override fun launch(context: Context, options: Bundle?): Boolean { val launcherApps = context.getSystemService()!! - if (isMainProfile) { - val intent = Intent() - intent.component = ComponentName(`package`, activity) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - return context.tryStartActivity(intent, options) - } else { - try { - launcherApps.startMainActivity( - ComponentName(`package`, activity), - launcherActivityInfo.user, - null, - options - ) - } catch (e: SecurityException) { - return false - } catch (e: ActivityNotFoundException) { - return false - } + try { + launcherApps.startMainActivity( + ComponentName(`package`, activity), + launcherActivityInfo.user, + null, + options + ) + } catch (e: SecurityException) { + return false + } catch (e: ActivityNotFoundException) { + return false } return true }