Adobe Flex的从相机胶卷移动选择的图像或拍照重新启动应用程序 [英] Adobe Flex mobile selecting image from camera roll or taking picture restarts the application

查看:157
本文介绍了Adobe Flex的从相机胶卷移动选择的图像或拍照重新启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的工作,我有与轧辊选择图像/拍照问题柔性的移动应用程序。我的应用程序没有标签,但它的一个部分包含一个标签视图导航与整个底部的标签。在这些选项卡之一,我必须将图像上传到我创建了一个Web服务的能力。然而,当我选择一个图像或拍摄照片,它弹出背出初始闪屏和应用程序重新启动。如果我使用的组件独立的(选项卡式视图导航之外)则选择没有任何问题的图像,并上传。

I have a flex mobile application that I am working on that I am having issues with selecting an image from roll/taking a picture. My application is not tabbed, however one part of it contains a Tabbed View Navigator with tabs across the bottom. Within one of those tabs, I have the ability to upload an image to a webservice that I have created. However, when I select an image or take the picture, it pops back out to the initial splash screen and the application restarts. If I use the component standalone (outside of the tabbed view navigator) it selects the image and uploads without any problem.

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

Concern.Uploads:

Concern.Uploads:

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

                      私人VAR的URLRequest:的URLRequest =新ULRequest(HTTP://mywebservice.php);             私人var文件:文件;

private var urlRequest:URLRequest = new ULRequest("http://mywebservice.php"); private var file:File;

        //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>

感谢您事先的任何帮助。

Thank you in advance for any assistance.

JH

推荐答案

我已经得到了类似的行为,最近加了我的见解,<一个href="http://stackoverflow.com/questions/8512165/flashbuilder-4-5-android-camera-restarting-my-application/9037019#9037019%29">another问题。我看到的东西的发行说明,AIR 2.5有关Android的杀死你的过程中,当摄像头资源不足的可能性。

I have gotten similar behavior and recently added my insights to another question. I saw something in release notes for AIR 2.5 about the possibility of Android killing your process when the camera is low on resources.

我认为这是一个FOL至少有一段时间,我提交了错误报告(#3099508)与Adobe。我发现,如果我关掉数据和GPS,因此降低目前正在使用的资源,我有工作的机会较大。非常令人沮丧,但我还没有看到任何解决方法。在我的应用程序,我会通过一个音符(共享对象)来检测的情况时,我$才去拍照p $ PSS按钮,然后清除它,当它返回,但如果应用程序启动与笔记集,我会提出了一个对话框,建议降低资源,这是一个AIR错误。

I think it is a FOL for at least awhile, I filed a bug report (#3099508) with Adobe. I have found if I turn off Data and GPS, so lower the resources being used currently, I have a greater chance of it working. Very frustrating, but I haven't seen any workaround. In my app, I am going to detect the situation by making a note (shared object) when I press the button before going to the camera, then clear it when it returns, but if the app starts with that note set, I will put up a dialog box advising to lower resources and this is an AIR bug.

这篇关于Adobe Flex的从相机胶卷移动选择的图像或拍照重新启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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