fall back to the generic way of launching apps, if one doesnt work

This commit is contained in:
tibbi 2022-10-14 12:17:47 +02:00
parent e91917bf1a
commit 661ff469a8
1 changed files with 6 additions and 4 deletions

View File

@ -1,7 +1,6 @@
package com.simplemobiletools.launcher.extensions
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.content.Intent
import android.net.Uri
@ -26,10 +25,13 @@ fun Activity.launchApp(packageName: String, activityName: String) {
addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
startActivity(this)
}
} catch (e: ActivityNotFoundException) {
showErrorToast(e)
} catch (e: Exception) {
showErrorToast(e)
try {
val launchIntent = packageManager.getLaunchIntentForPackage(packageName)
startActivity(launchIntent)
} catch (e: Exception) {
showErrorToast(e)
}
}
}