摄像头活动不返回结果保存后 [英] Camera activity does not return a result after save
本文介绍了摄像头活动不返回结果保存后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个code为拍照和pviously在地图上$ P $显示它们。即使我没'T改变的那部分相关code,它不会安装的Android 2.3.6之后的工作。我调试的code和code不会进入的onActivityResult方法。我无法分辩现在调试在其他版本的软件。任何一个可以帮助我这个问题。相关code为如下:
保护无效startCameraActivity(){
文件文件目录=新的文件(Environment.getExternalStorageDirectory()+文件路径);
//有对象建立的目录结构,如果需要的话。
fileDirectory.mkdirs();
图像NUMBER ++;
档案文件=新的文件(文件目录,image_+图像NUMBER
+.JPG);
如果(file.exists())file.delete();
乌里outputFileUri = Uri.fromFile(文件);
的ImagePath = file.toString();
意向意图=新意图(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,outputFileUri); startActivityForResult(意向,0);
}
@覆盖
保护无效的onActivityResult(INT申请code,INT结果code,意图数据){
开关(结果code){
情况1:
//这个code执行有关保存的图像文件操作
新LongOperation()执行();
打破;
}
开关(要求code){
案例3:
enableGPS();
打破;
}
}
解决方案
添加在的onActivityResult)这一行(
super.onActivityResult(要求code,结果code,数据);
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;
}
}
解决方案
Add this line in onActivityResult()
super.onActivityResult(requestCode, resultCode, data);
这篇关于摄像头活动不返回结果保存后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文