I want the user to be able to quickly open the default camera app (or one they have set as default) in my app. However, I do not want to use android.media.action.IMAGE_CAPTURE, as this will only show the photo taking portion of the app. I just want to simply open the camera app without using this. I do know that this is possible, as several gallery apps that I have used (Most notibale: Focus) have been able to just simply open the camera app with no issue, and did not use IMAGE_CAPTURE.
This can be achieved by using PackageManager#resolveActivity(Intent)
In Kotlin:
val info: ResolveInfo? = packageManager
.resolveActivity(cameraIntent);
if (info == null) {
// No camera app installed.
return
}
// Documentation says at least one of the three infos is not-null:
val app: ApplicationInfo = info.activityInfo?.applicationInfo
?: info.serviceInfo?.applicationInfo
?: info.providerInfo!!.applicationInfo
val launch: Intent? = packageManager
.getLaunchIntentForPackage(app.packageName)
if (launch == null) {
// Camera app has no default intent.
return
}
// Launch the camera intent's
// resolved app's default activity.
context.startActivity(launch)
(Where cameraIntent
is the Intent created using the android.media.action.IMAGE_CAPTURE
filter, context
is the current app context and packageManager
is the context's PackageManager
instance.)