safeStartActivity extension
This commit is contained in:
parent
1ffe50bdae
commit
b2e3d6b0f0
|
|
@ -0,0 +1,12 @@
|
|||
package ru.touchin.roboswag.components.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
fun Context.safeStartActivity(intent: Intent, flags: Int = 0): Boolean =
|
||||
if (packageManager.resolveActivity(intent, 0) != null) {
|
||||
startActivity(intent)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
Loading…
Reference in New Issue