当控制转到三星 Galaxy Ace(Android 版本 2.3.6)上的 firstActivity 时,不会调用 OnActivityResult(),但它在三星 Galaxy Fit(Android 版本 2.3.6)上可以正常工作。请帮我...
以下是我的代码:
在第一个活动中
Intent intent = new Intent(this,CameraActivity.class);
startActivityForResult(intent, 2);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
photo = data.getByteArrayExtra("image_data");
Bitmap bitmap = BitmapFactory.decodeByteArray(photo ,0,photo.length);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.JPEG,75, bos);
data1 = bos.toByteArray();
bab = new ByteArrayBody(data1, ""+ ConsumerNo.getText() +".JPEG");
}
}
在第二个活动中:
@Override
public void onPictureTaken(byte[] data, Camera camera) {
data1 = data;
if(data1 == null)
{
Log.d("==========>>>>>", "nuuullllllllllllll");
}
FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
preview.setVisibility(View.GONE);
Button captureButton = (Button) findViewById(R.id.button_capture);
captureButton.setVisibility(View.GONE);
imageView = (ImageView)findViewById(R.id.imageView1);
saveButton=(Button) findViewById(R.id.saveBtn);
newButton=(Button) findViewById(R.id.newBtn);
imageView.setVisibility(View.VISIBLE);
saveButton.setVisibility(View.VISIBLE);
newButton.setVisibility(View.VISIBLE);
ImageView imageBut= (ImageView)findViewById(R.id.imageView1);
bitmap = BitmapFactory.decodeByteArray(data , 0, data .length);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.JPEG,75, bos);
imageBut.setImageBitmap(bitmap);
saveButton.setOnClickListener(CameraActivity.this);
newButton.setOnClickListener(CameraActivity.this);
}
if(((Button)v).getId() == saveButton.getId())
{
intent = getIntent();
intent.putExtra("image_data", data1);
setResult(RESULT_OK, intent);
finish();
}