You are running this code on an Android environment that lacks the Google Play Store, such as an emulator, Kindle Fire, etc.
If you are encountering this on an emulator, test this code path on a device that has the Play Store.
If you are encountering this on some piece of hardware that lacks the Play Store, or if you are planning on distributing your app to devices that lack the Play Store, either handle the exception or use PackageManager
and resolveActivity()
to determine if your Intent
will succeed before calling startActivity()
.
if(intent.resolveActivity(getPackageManager()) != null)
startActivityForResult(intent, 0);
else
...