The following code works most of the time:
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/internal/images/media"));
startActivity(intent);
It throws the following exception sometimes (reported by error log from users):
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://media/internal/images/media }
Stack trace:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://media/internal/images/media } at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1899) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1589) at android.app.Activity.startActivityForResult(Activity.java:4228) at android.support.v4.app.k.startActivityForResult(SourceFile:50) at android.support.v4.app.p.startActivityForResult(SourceFile:79) at android.app.Activity.startActivityForResult(Activity.java:4187) at android.support.v4.app.p.startActivityForResult(SourceFile:859) at android.app.Activity.startActivity(Activity.java:4515) at android.app.Activity.startActivity(Activity.java:4483)
I am wondering if some users' Android devices do not have Gallery.
I am wondering if some users' Android devices do not have Gallery.
There is no requirement for any Android device to have any exported activity that supports that particular Intent
structure (ACTION_VIEW
for whatever MIME type is tied to that Uri
, plus a content
scheme).
Beyond that, there is no single app named "Gallery". Out of ~2 billion devices and ~10,000 device models, there may be hundreds of apps that serve this general role, and a device might not have any such app.
What is a reliable way to open Gallery on Android?
See CATEGORY_APP_GALLERY
, and be sure to handle the case where there is no matching activity.