Camera activity does not return a result after sav

2019-08-20 08:41发布

I had a code for taking photos and displaying them on map previously. Even i didn' t change the code related with that part, it doesn't work after installing android 2.3.6. I debugged the code and the code does not go into onActivityResult method. I could not debug the software in other versions rigth now. Can any one help me about the problem. Related code is given below:

    protected void startCameraActivity() {
File fileDirectory = new File(Environment.getExternalStorageDirectory()+ filePath);
        // have the object build the directory structure, if needed.
        fileDirectory.mkdirs();
        imageNumber++;
        File file = new File(fileDirectory, "image_" + imageNumber
                + ".jpg");
        if (file.exists()) file.delete();
        Uri outputFileUri = Uri.fromFile(file);
        imagePath = file.toString();
        Intent intent = new Intent(
                android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);

        startActivityForResult(intent, 0);
}
@Override   
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (resultCode) {
    case -1:
        // this code performs operations about the saved image file
        new LongOperation().execute("");
        break;
    }
    switch (requestCode) {
    case 3:
    enableGPS();    
    break;
    }
}

2条回答
我只想做你的唯一
2楼-- · 2019-08-20 09:03

Add this line in onActivityResult()

    super.onActivityResult(requestCode, resultCode, data);
查看更多
登录 后发表回答