安卓:在调用摄像头意图后活动被破坏掉了 [英] Android: Activity getting Destroyed after calling Camera Intent

查看:168
本文介绍了安卓:在调用摄像头意图后活动被破坏掉了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个活动(A1,A2)。 A1 A2调用,并从A2我打电话相机意图如下

I am having two Activities (A1 , A2). A1 calls A2 and from A2 i am calling the camera intent as below

launchIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
launchIntent.putExtra(MediaStore.EXTRA_OUTPUT,photoPath);   
startActivityForResult(launchIntent,CAMERA_REQUEST);

它打开相机,我可以拍摄照片。但问题出现了,一旦我点击保存按钮(打勾的S3按钮),我的 onActivityResult 不叫,而不是A2的的onDestroy方法被调用。我有一些逻辑在onActivityResult FN来完成。

It opens the camera, and i can take the picture. But the Problem arises once i click the save button (tick button in s3), my onActivityResult is not called instead A2's onDestroy method is called. I have few logics to be done in the onActivityResult fn.

我读了一些后在#1关于这一点,但我不能得到有用的输出that.I有我的表现像这样我的第二个活动(A2)

I had read some post in Stackoverflow regarding this but i couldnt get useful output from that.I have my manifest like this for my second Activity(A2)

android:configChanges="keyboardHidden|orientation|locale"
android:screenOrientation="portrait

注意:在HTC One X的我onActivityResult FN获取调用,但在我的S3次活动(A2)是被破坏掉了。

Note: In HTC One X my onActivityResult fn is getting called, but in my S3 second Activity(A2) is getting destroyed

PLZ分享乌尔这个想法。在此先感谢

Plz share ur thoughts on this. Thanks in Advance

推荐答案

我有同样的疑难问题将是疯了,但最后我找到了解决办法<一href="http://stackoverflow.com/questions/16154279/galaxy-s3-taking-picture-in-portrait-mode-destroys-activity">here. 问题是,当你点击保存按钮,相机的活动呼吁改变方向的方法,它会破坏并重新创建。 尝试设置

i had the same problem.i will be crazy but finally i have found a solution here. the issue is that when you click on "save" button of the camera the activity call change orientation method and it will destroy and recreated. try to set

安卓configChanges =方向|屏幕尺寸

在Android清单(不仅安卓configChanges =定向,因为作为建议<一href="http://stackoverflow.com/questions/3329318/android-how-to-not-destroy-the-activity-when-i-rotate-the-device">here,如果不是因为API级别13或更高)的工作。

in android manifest (not only android:configChanges="orientation" because as suggest here, it not work for API level 13 or higher).

其prevent破坏活动,它为我工作。

it prevent to destroy activity,it work for me.

这篇关于安卓:在调用摄像头意图后活动被破坏掉了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆