How to launch an Activity from another app in Android on Kotlin
Hello colleagues! I'm a beginner Android developer in Kotlin, and I've run into a problem. I'm writing a launcher app that should open Activities from other installed apps. For example, I want to open the camera or maps by pressing a button. But I don't understand how to properly compose an Intent and what data to pass to it.\n\nHere's what I tried:\n\n```kotlin\nval intent = Intent()\nintent.action = Intent.ACTION_VIEW\nintent.data = Uri.parse("com.example.targetapp")\nstartActivity(intent)\n```\n\nBut this causes a crash with the error `android.content.ActivityNotFoundException`. I also tried getting the PackageManager and calling `getLaunchIntentForPackage()`:\n\n```kotlin\nval pm = packageManager\nval intent = pm.getLaunchIntentForPackage("com.whatsapp")\nstartActivity(intent)\n```\n\nThis works