Camera Activity not found?

2019-08-06 05:26发布

问题:

I've released an app and in the logs, I'm getting this message several times

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.MAIN pkg=com.android.camera } 

I'm calling the camera like this

final Intent mainCameraIntent = new Intent();
mainCameraIntent.setPackage("com.android.camera");
mainCameraIntent.setAction("android.intent.action.MAIN");
startActivity(mainCameraIntent);

Why am getting this message? On my device (2.3.3), it works fine. I had issues with 2.1 devices before and also with proguard removing blocks of code, but I'm not sure if this is related to any of those

回答1:

Why am getting this message?

Because you should not be using this Intent. Not all devices will have com.android.camera.