Camera activity does not return a result after save

血红的双手。 提交于 2019-12-25 02:43:12

问题


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;
    }
}

回答1:


Add this line in onActivityResult()

    super.onActivityResult(requestCode, resultCode, data);



回答2:


After some research I fond a solution: The problem with an external camera in Android using MediaStore.ACTION_IMAGE_CAPTURE



来源:https://stackoverflow.com/questions/8624056/camera-activity-does-not-return-a-result-after-save

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!