Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Phonegap getPicture功能长延迟,召回后恢复_Javascript_Android_Cordova_Cordova 3 - Fatal编程技术网

Javascript Phonegap getPicture功能长延迟,召回后恢复

Javascript Phonegap getPicture功能长延迟,召回后恢复,javascript,android,cordova,cordova-3,Javascript,Android,Cordova,Cordova 3,我在Android设备上的Cordova/Phonegap 3.2应用程序中拍摄照片时遇到问题 当我运行navigator.camera.getPicture函数时,相机会在大约30秒(有时更长)后返回成功。但是,当我再次点击相机按钮(再次运行navigator.camera.getPicture函数,而不捕获快照)时,它会将控件返回到应用程序并恢复应用程序的进程 它看起来像是在我拍摄图像后卡住的应用程序(尽管我在相机拍摄完照片后返回应用程序),唯一导致相机继续运行并进入成功功能的是再次运行ge

我在Android设备上的Cordova/Phonegap 3.2应用程序中拍摄照片时遇到问题

当我运行
navigator.camera.getPicture
函数时,相机会在大约30秒(有时更长)后返回成功。但是,当我再次点击相机按钮(再次运行navigator.camera.getPicture函数,而不捕获快照)时,它会将控件返回到应用程序并恢复应用程序的进程

它看起来像是在我拍摄图像后卡住的应用程序(尽管我在相机拍摄完照片后返回应用程序),唯一导致相机继续运行并进入
成功功能的是再次运行
getPicture
功能

这在iOS7上不会发生,我只在Android上体验过(在Android版本2.3.5、4.1.2中尝试过)

我在调用
navigator.camera.getPicture
之前放置了一个警报,它运行正常。我还在success函数中添加了一个警报,但它没有运行。因此,我假设捕获插件中的其他内容会导致延迟

我已经检查了CPU,它是低的。我禁用了任何其他后台进程和webservice调用,以确保它不会导致这种行为

我还使用了非常小的图像大小,以确保图像的大尺寸不会导致此问题。因此,我还消除了图像大小因子

getPicture函数:

 navigator.camera.getPicture(function () {   
        // On get photo success

        that._onPhotoURISuccess.apply(that, arguments);
         return false;
    }, function (err) {


    }, {
        quality: CAPTURED_PHOTO_IMAGE_QUALITY,
        destinationType: Camera.DestinationType.FILE_URI, 
        encodingType: Camera.EncodingType.JPEG,
        saveToPhotoAlbum: SETTINGS_SAVE_TO_PHOTO_ALBUM,
        allowEdit: false,
        sourceType: Camera.PictureSourceType.CAMERA, 
        targetWidth: maxSize, // <= 1024
        targetHeight: maxSize, 
        correctOrientation: true,  
    });
navigator.camera.getPicture(函数(){
//论摄影的成功
应用(即参数);
返回false;
},函数(err){
}, {
质量:拍摄的照片质量,
destinationType:Camera.destinationType.FILE\u URI,
编码类型:Camera.encodingType.JPEG,
saveToPhotoAlbum:SETTINGS\u SAVE\u TO\u PHOTO\u相册,
允许:错误,
源类型:Camera.PictureSourceType.Camera,

targetWidth:maxSize,//我在phonegap 2.9.0上遇到了同样的问题,在做了许多失败的尝试来解决这个问题后,我做了以下几点

  • 我创建了一个新的phonegap 3.5.0项目

  • 我从CLI构建了android平台

  • 我将www文件夹复制到新的项目根文件夹

  • 我使用CLI添加了所有需要的插件

  • 我对图标和启动屏幕的顶级config.xml文件做了必要的更改,因为文件结构不同

  • 我负责这个项目,现在一切正常


请提供调用getPicture的代码好吗?以及,您是否尝试过cordova 3.3/3.4?嗨,已使用该代码进行更新。由于ApplicationBuilder环境的限制,我无法使用cordova 3.2以外的版本。不过,我正在使用最新版本的文件、文件传输、媒体捕获和相机插件。您已经使用
t进行了测试argetsize
,您是否也尝试过使用不同的(小的)
质量
值?我在我们的应用程序和android上使用它,第一次启动速度很慢,但在手机上平均启动时间约为2-3秒。::我尝试了10px大小的图像,质量为10,问题相同。这家伙也有同样的问题:@paolocascello我用相关的调试跟踪和更详细的信息更新了问题。
03-27 21:11:10.812: V/webview(11988):  singleCursorHandlerTouchEvent -getEditableSupport  FASLE 
03-27 21:11:11.281: D/CordovaActivity(11988): Paused the application!
03-27 21:11:11.281: D/CordovaWebView(11988): Handle the pause
03-27 21:11:11.296: W/PluginManager(11988): THREAD WARNING: exec() call to Camera.takePicture blocked the main thread for 33ms. Plugin should use CordovaInterface.getThreadPool().
03-27 21:11:11.382: W/PluginManager(11988): THREAD WARNING: exec() call to WebSocket.send blocked the main thread for 18ms. Plugin should use CordovaInterface.getThreadPool().
03-27 21:11:12.117: W/IInputConnectionWrapper(11988): showStatusIcon on inactive InputConnection
03-27 21:11:17.070: D/CordovaActivity(11988): Incoming Result
03-27 21:11:17.070: D/CordovaActivity(11988): Request code = 34
03-27 21:11:17.070: D/CordovaActivity(11988): We have a callback to send this result to
03-27 21:11:17.585: D/dalvikvm(11988): GC_EXTERNAL_ALLOC freed 563K, 52% free 4167K/8519K, external 5208K/5208K, paused 85ms
03-27 21:11:18.734: D/dalvikvm(11988): GC_EXPLICIT freed 19K, 52% free 4161K/8519K, external 8280K/8422K, paused 64ms
03-27 21:11:18.750: D/Whitelist(11988): Unlimited access to network resources
03-27 21:11:18.757: I/CordovaLog(11988): Found start page location: index.html
03-27 21:11:18.757: D/Config(11988): The <log> tags is deprecated. Use <preference name="loglevel" value="DEBUG"/> instead.
03-27 21:11:18.757: I/CordovaLog(11988): Changing log level to DEBUG(3)
03-27 21:11:18.757: D/CordovaActivity(11988): Resuming the App
03-27 21:11:18.757: D/CordovaActivity(11988): CB-3064: The errorUrl is null
03-27 21:11:18.789: V/webview(11988): OnSizeChanged: Enter 
03-27 21:11:18.804: D/SoftKeyboardDetect(11988): Ignore this event
03-27 21:11:19.125: V/webview(11988): OnSizeChanged: Enter 
03-27 21:13:07.539: D/dalvikvm(11988): GC_CONCURRENT freed 2057K, 52% free 4189K/8647K, external 408K/5208K, paused 4ms+5ms
03-27 21:13:37.539: D/dalvikvm(11988): GC_CONCURRENT freed 574K, 52% free 4177K/8647K, external 408K/5208K, paused 4ms+4ms
03-27 21:13:57.515: V/webview(11988):  singleCursorHandlerTouchEvent -getEditableSupport  FASLE 
03-27 21:13:57.984: D/CordovaActivity(11988): Paused the application!
03-27 21:13:57.984: D/CordovaWebView(11988): Handle the pause
03-27 21:13:58.000: W/PluginManager(11988): THREAD WARNING: exec() call to Camera.takePicture blocked the main thread for 33ms. Plugin should use CordovaInterface.getThreadPool().
03-27 21:13:58.351: D/FileTransfer(11988): upload file:///mnt/sdcard/Android/data/com.test.test/cache/1395947477121.jpg to http://test.test.com/service.asmx/SaveImage
03-27 21:13:58.351: D/FileTransfer(11988): fileKey: file
03-27 21:13:58.351: D/FileTransfer(11988): fileName: 26346703-41cc-452c-8e86-aac088c99781.jpg
03-27 21:13:58.351: D/FileTransfer(11988): mimeType: image/jpeg
03-27 21:13:58.359: D/FileTransfer(11988): params: {}
03-27 21:13:58.359: D/FileTransfer(11988): trustEveryone: false
03-27 21:13:58.367: D/FileTransfer(11988): chunkedMode: false
03-27 21:13:58.367: D/FileTransfer(11988): headers: {"Connection":"close"}
03-27 21:13:58.367: D/FileTransfer(11988): objectId: 4
03-27 21:13:58.398: D/FileTransfer(11988): httpMethod: POST
03-27 21:13:58.398: W/PluginManager(11988): THREAD WARNING: exec() call to FileTransfer.upload blocked the main thread for 96ms. Plugin should use CordovaInterface.getThreadPool().
03-27 21:13:58.398: D/FileTransfer(11988): Content Length: 28412
03-27 21:13:58.625: D/dalvikvm(11988): GC_CONCURRENT freed 453K, 51% free 4312K/8647K, external 408K/5208K, paused 4ms+5ms
03-27 21:13:58.914: D/FileTransfer(11988): Sent 28412 of 28412
03-27 21:13:59.156: W/IInputConnectionWrapper(11988): showStatusIcon on inactive InputConnection
03-27 21:13:59.257: D/FileTransfer(11988): response code: 200
03-27 21:13:59.281: D/FileTransfer(11988): response headers: {null=[HTTP/1.1 200 OK], Access-Control-Allow-Headers=[Content-Type], Access-Control-Allow-Origin=[*], Cache-Control=[private, max-age=0], Connection=[Close], Content-Length=[0], Date=[Thu, 27 Mar 2014 19:14:50 GMT], Server=[Microsoft-IIS/8.0], X-Android-Received-Millis=[1395947639258], X-Android-Response-Source=[NETWORK 200], X-Android-Sent-Millis=[1395947638596], X-AspNet-Version=[4.0.30319], X-Powered-By=[ASP.NET]}
03-27 21:13:59.281: D/FileTransfer(11988): got response from server
03-27 21:14:00.796: D/CordovaActivity(11988): Incoming Result
03-27 21:14:00.796: D/CordovaActivity(11988): Request code = 34
03-27 21:14:00.796: D/CordovaActivity(11988): We have a callback to send this result to
03-27 21:14:00.835: D/Whitelist(11988): Unlimited access to network resources
03-27 21:14:00.843: I/CordovaLog(11988): Found start page location: index.html
03-27 21:14:00.843: D/Config(11988): The <log> tags is deprecated. Use <preference name="loglevel" value="DEBUG"/> instead.
03-27 21:14:00.976: I/CordovaLog(11988): Changing log level to DEBUG(3)
03-27 21:14:00.976: D/CordovaActivity(11988): Resuming the App
03-27 21:14:00.976: D/CordovaActivity(11988): CB-3064: The errorUrl is null
03-27 21:14:01.070: V/webview(11988): OnSizeChanged: Enter 
03-27 21:14:01.078: D/SoftKeyboardDetect(11988): Ignore this event
03-27 21:14:01.289: V/webview(11988): OnSizeChanged: Enter 
03-27 21:14:01.609: D/skia(11988): purging 197K from font cache [29 entries]