我的onCreate():ACTION_IMAGE_CAPTURE不會調用onActivityResult?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imageFile = new File(Environment.getExternalStorageDirectory(),
"/image.jpg");
System.out.println(imageFile +" is the path with extentions");
outputFileUri = Uri.fromFile(imageFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, TAKE_PICTURE);
setContentView(R.layout.activity_head_size);
System.out.println("OnCreate");
}
顯然,啓動相機並等待它完成並返回圖像。當完成後,它應該叫
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
然而,當我點擊保存在相機,它加載的onCreate並重新運行相機。然後,如果您重新拍攝了圖像並將其保存到活動中,但是,不運行onActivityResult?到底是怎麼回事?
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode == 1){
myImage = (ImageView) findViewById(R.id.imageView1);
myBitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() +
"/image.jpg");
myBitmap = Bitmap.createScaledBitmap(myBitmap, 256, 256, false);
myImage.setImageBitmap(myBitmap);
width = myBitmap.getWidth();
height = myBitmap.getHeight();
orig = new int[width*height];
myBitmap.getPixels(orig, 0, width, 0, 0, width, height);
System.out.println("ready for processing");
}
}
我已經回答了這個問題之前 看看: http://stackoverflow.com/a/30266776/1531683 –
我已經回答了這個問題之前 看看: HTTP://計算器.com/a/30266776/1531683 –