My android application was working fine on all android devices from version 2.3 to 4.4. However, when i updated my Samsung Galaxy S4 to LOLLIPOP and tested the said app, there are a few errors in functionalities such as camera,map etc.
Below is the code snippet used in my application to utilize the native camera:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult( requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK && null != data)
{
Bitmap camImg = (Bitmap) data.getExtras().get("data");
}
}
Here I am getting (Bitmap) data.getExtras().get("data") as null. Is there any alternate solution for this code. Any help would be appreciated.
You would appear to be following the documentation, and it would appear that the camera app that is being chosen here is not.
This is one of the risks in delegating work like this to a third-party app -- third-party apps can have bugs.
Your choices are:
Switch to using EXTRA_OUTPUT
to specify a Uri
for a full-size image. In your results, if you do not have the data
Bitmap
, try reading in the full-size image, using BitmapFactory.Options
to down-sample it to something more appropriately sized. There may still be camera apps that honor ACTION_IMAGE_CAPTURE
that do not work, but it should reduce the number of such broken apps.
Use the android.hardware.Camera
or android.hardware.camera2
APIs yourself, and avoid relying upon a third-party app.
I would have to disagree with CommonsWare on this one. I am using the android.hardware.Camera with my app and testing with a Samsung Galaxy S4 running Lollipop. It seems the problem is that onCreate is called before onActivityResult when running the app on Samsung Lollipop.
My suggestion is to set the max target in your app to 20 (Android 4.4) until Samsung sorts this out. It is a Samsung issue.
android:maxSdkVersion="20"