06-01 07:48:47.956: W/Camera(6961): Camera server died!
06-01 07:48:47.956: W/Camera(6961): ICamera died
06-01 07:48:47.956: E/Camera(6961): Error 100
クラスを呼び出して画像をキャプチャし、その画像を処理して (640*480 に圧縮)、lat、lng、md_code などの他のデータと共にサーバーに送信しています。
Galaxy Note IIではすべて正常に動作しますが、小さなデバイスのフロントカメラ(Galaxy S Advance)でこれをテストしようとすると、このエラーが表示されます.is ti device problem
私のコードは次のとおりです
アクティビティからの呼び出し
// checking a camera?
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA))
{
Toast.makeText(this, "No camera on this device", Toast.LENGTH_LONG).show();
}
else
{
cameraId = findFrontFacingCamera();
if (cameraId < 0)
{
Toast.makeText(this, "Sorry you don't have secondary camera",Toast.LENGTH_LONG).show();
//Exit from application
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
else
{
camera = Camera.open(cameraId);
}
}
private int findFrontFacingCamera()
{
int cameraId = -1;
// Search for the front facing camera
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++)
{
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(i, info);
if (info.facing == CameraInfo.CAMERA_FACING_FRONT)
{
Log.d(DEBUG_TAG, "Front Facing Camera found");
cameraId = i;
break;
}
}
return cameraId;
}
//Calling camara to capture
camera.takePicture(null, null,new PhotoHandler(getApplicationContext(), code, pwd, InOutAb, serverPort));
PhotoHandler クラス
public class PhotoHandler implements PictureCallback {
private final Context context;
String mdCode,pass,state,serverPortAddress;
public PhotoHandler(Context context, String code, String pwd,String InOutAb,String serverPort) {
this.context = context;
mdCode = code;
pass = pwd;
state = InOutAb;
serverPortAddress = serverPort;
}
@Override
public void onPictureTaken(byte[] imgData, Camera camera) {
//Compressing the image 640*480
//-----------------------------------------
Bitmap bmp=BitmapFactory.decodeByteArray(imgData, 0, imgData.length);
Bitmap resizedBmp = Bitmap.createScaledBitmap(bmp, 640, 480, false);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
resizedBmp.compress(CompressFormat.PNG, 0, bos);
byte[] data = bos.toByteArray();
//-----------------------------------------
File pictureFileDir = getDir();
if (!pictureFileDir.exists() && !pictureFileDir.mkdirs()) {
Toast.makeText(context, "Can't create directory to save image.",Toast.LENGTH_LONG).show();
return;
}
String photoFile = "MyPicture.jpg";
String filename = pictureFileDir.getPath() + File.separator + photoFile;
File pictureFile = new File(filename);
try
{
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
Toast.makeText(context, "New Image saved:" + filename,Toast.LENGTH_LONG).show();
}
catch (Exception error)
{
Log.d("Exception", error+"");
Toast.makeText(context, "Image could not be saved.",Toast.LENGTH_LONG).show();
}
}
private File getDir()
{
File sdDir = Environment.getExternalStorageDirectory();
return new File(sdDir, "Attendance Image");
}
}
**Not even single success toast is given only showing this error**