Apache flex AdobeFlex mobile从相机卷或拍照中选择图像将重新启动应用程序

Apache flex AdobeFlex mobile从相机卷或拍照中选择图像将重新启动应用程序,apache-flex,upload,camera,adobe,Apache Flex,Upload,Camera,Adobe,我有一个正在开发的flex mobile应用程序,在从滚动/拍照中选择图像时遇到问题。我的应用程序不是选项卡式的,但是它的一部分包含一个选项卡式视图导航器,底部有选项卡。在其中一个选项卡中,我能够将图像上传到我创建的Web服务。但是,当我选择图像或拍照时,它会弹出到初始启动屏幕,应用程序会重新启动。如果我使用独立组件(在选项卡式视图导航器之外),它会选择图像并毫无问题地上传 <s:TabbedViewNavigator id="tvn" width="100%" height="100%"

我有一个正在开发的flex mobile应用程序,在从滚动/拍照中选择图像时遇到问题。我的应用程序不是选项卡式的,但是它的一部分包含一个选项卡式视图导航器,底部有选项卡。在其中一个选项卡中,我能够将图像上传到我创建的Web服务。但是,当我选择图像或拍照时,它会弹出到初始启动屏幕,应用程序会重新启动。如果我使用独立组件(在选项卡式视图导航器之外),它会选择图像并毫无问题地上传

<s:TabbedViewNavigator id="tvn" width="100%" height="100%">
    <s:ViewNavigator icon="@Embed('assets/icons/contact.png')"  label="contact" width="100%" height="100%" firstView="Concern.ContactInfo" firstViewData="{data}"/>
    <s:ViewNavigator icon="@Embed('assets/icons/notes.png')" label="details" width="100%" height="100%" firstView="Concern.Description"  firstViewData="{data}"/>
    <s:ViewNavigator icon="@Embed('assets/icons/updates.png')" label="updates" width="100%" height="100%" firstView="Concern.Updates"  firstViewData="{data}"/>
    <s:ViewNavigator icon="@Embed('assets/icons/upload.png')" label="uploads" width="100%" height="100%" firstView="Concern.Uploads" firstViewData="{data}"/>
</s:TabbedViewNavigator>

关注:上传:

<?xml version="1.0" encoding="utf-8"?>

private var urlRequest:urlRequest=new-ULRequest(“http://mywebservice.php"); 私有var文件:文件

        //take a new picture with the camera
        protected function uploadCamera_clickHandler(event:MouseEvent):void
        {
            if (CameraUI.isSupported)
            {
                trace("camera is supported");
                var myCam:CameraUI = new CameraUI();
                myCam.launch(MediaType.IMAGE);
                myCam.addEventListener(MediaEvent.COMPLETE,selectCompleteHandler);
            }
            else
            {
                trace("camera not supported");
                statusText.text = "Camera not supported on this device.";
            }
        }

        //select a picture from the camera roll (gallery)
        protected function uploadGallery_clickHandler(event:MouseEvent):void
        {
            if (CameraRoll.supportsBrowseForImage)
            {
                trace("camera roll is supported");
                var roll:CameraRoll = new CameraRoll();
                roll.browseForImage();
                roll.addEventListener(MediaEvent.SELECT,selectCompleteHandler);
            }
            else
            {
                trace("camera roll not supported");
                statusText.text = "Camera roll not supported on this device.";
            }
        }

        //when the selection is complete upload it
        protected function selectCompleteHandler(event:MediaEvent):void
        {
            trace("event.data.file.url; = "+event.data.file.url);
            takePhotoButton.enabled = galleryPhotoButton.enabled = false;
            file = event.data.file;
            file.addEventListener(Event.COMPLETE,uploadCompleteHandler);
            file.addEventListener(Event.OPEN,openUploadHandler);
            urlRequest = new URLRequest("http://MyWebService.php?ID=" + data.ID.toString());
            statusText.text = "Uploading please wait...";
            file.upload(urlRequest);                
        }

        protected function uploadCompleteHandler(event:Event):void
        {
            trace("upload complete");
            takePhotoButton.enabled = galleryPhotoButton.enabled = true;
            statusText.text = "Photo Uploaded";
        }

        protected function openUploadHandler(event:Event):void
        {
            trace("uploading");
            statusText.text = "Uploading...";
        }
    ]]>
</fx:Script>
<s:Image source="@Embed('assets/i/logo.jpg')" horizontalAlign="center" horizontalCenter="0" bottom="0"/>
<s:Label width="100%" id="res" textAlign="left"/>
<s:Scroller width="100%" height="100%">
    <s:VGroup width="100%" height="100%" verticalAlign="top" paddingLeft="15" paddingRight="15" horizontalAlign="center">
        <s:VGroup width="100%" paddingTop="15">
            <s:Label text="My Header" styleName="cityTitle" width="100%">
                <s:filters>
                    <s:DropShadowFilter color="#000000"/>
                </s:filters>
            </s:Label>
            <s:Label text="Portal" styleName="citySubtitle" width="100%">
                <s:filters>
                    <s:DropShadowFilter color="#000000"/>
                </s:filters>
            </s:Label>
        </s:VGroup>
        <s:VGroup horizontalAlign="center" gap="25" width="100%">
            <s:Button id="takePhotoButton" label="Take Photo" click="uploadCamera_clickHandler(event)" minHeight="50" width="50%"/>
            <s:Button id="galleryPhotoButton" label="From Gallery"
                      click="uploadGallery_clickHandler(event)" minHeight="50" width="50%"/>                
            <s:Label id="statusText" fontSize="24" text="" color="#FFFFFF"/>                
        </s:VGroup>
    </s:VGroup>
</s:Scroller>
//用相机拍一张新照片
受保护的函数上载Camera\u clickHandler(事件:MouseeEvent):无效
{
如果(CameraUI.Isupported)
{
跟踪(“支持摄像头”);
var myCam:CameraUI=新的CameraUI();
myCam.launch(MediaType.IMAGE);
myCam.addEventListener(MediaEvent.COMPLETE,selectCompleteHandler);
}
其他的
{
跟踪(“不支持摄像头”);
statusText.text=“此设备不支持摄像头。”;
}
}
//从相机卷(多媒体资料)中选择图片
受保护的函数uploadGallery\u clickHandler(事件:MouseeEvent):无效
{
if(摄像头支架支架支架支架支架)
{
跟踪(“支持摄像机辊”);
var roll:CameraRoll=新的CameraRoll();
roll.browseForImage();
roll.addEventListener(MediaEvent.SELECT,selectCompleteHandler);
}
其他的
{
跟踪(“不支持摄影机卷”);
statusText.text=“此设备不支持摄像头滚动。”;
}
}
//选择完成后,将其上载
受保护的函数selectCompleteHandler(事件:MediaEvent):无效
{
跟踪(“event.data.file.url;=”+event.data.file.url);
takePhotoButton.enabled=galleryPhotoButton.enabled=false;
file=event.data.file;
addEventListener(Event.COMPLETE,uploadCompleteHandler);
addEventListener(Event.OPEN,openUploadHandler);
urlRequest=新的urlRequest(“http://MyWebService.php?ID=“+data.ID.toString());
statusText.text=“正在上载,请稍候…”;
上传文件(URL请求);
}
受保护的函数uploadCompleteHandler(事件:事件):void
{
跟踪(“上传完成”);
takePhotoButton.enabled=galleryPhotoButton.enabled=true;
statusText.text=“照片上传”;
}
受保护的函数openUploadHandler(事件:event):void
{
跟踪(“上传”);
statusText.text=“上传…”;
}
]]>

提前感谢您的帮助


JH

我也有过类似的行为,最近我将自己的见解添加到了这个项目中。我在AIR2.5的发行说明中看到了一些关于Android可能在相机资源不足时终止您的进程的内容


我认为这是一个FOL,至少有一段时间,我向Adobe提交了一份bug报告(#3099508)。我发现,如果我关闭数据和GPS,那么当前使用的资源越少,我工作的机会就越大。非常令人沮丧,但我没有看到任何解决办法。在我的应用程序中,我会在去摄像头前按下按钮时记录(共享对象),然后在它返回时清除它来检测情况,但如果应用程序以该记录集启动,我会弹出一个对话框,建议减少资源,这是一个空气bug。

感谢您的回复,听起来可能是同一个问题。另外,感谢您在启动相机之前将数据保存到手机上的想法,这是一件痛苦的事情,但我相信我可以实现一种解决方法。