首页 文章

cordova-plugin-camera无法在Crosswalk Android上工作(适用于iOS)

提问于
浏览
0

我有一个离子(cordova / phonegap)应用程序,其中包括上传从设备相机或照片库中拍摄的照片 . 我通过ngCordova使用cordova插件,包括 cordova-plugin-cameracordova-plugin-file .

Android版本使用 CrossWalk engine .

我可以从库中选择图像或拍摄新照片 . 但是我的回调是't called so I' m无法使用结果 . N.B: everything works perfectly on iOS.

回调(未调用如下)回调位于'then'方法中 .

$scope.getPhoto = function(useLibarary) {
        var options = {
            destinationType: Camera.DestinationType.FILE_URI,
            sourceType: (useLibarary) ? Camera.PictureSourceType.PHOTOLIBRARY : Camera.PictureSourceType.Camera,
            encodingType: Camera.EncodingType.JPEG
        };

       $cordovaCamera.getPicture(options).then(function(imageURI) {
            // success
            //
            $scope.postImageSrc = imageURI;
            console.log(JSON.stringify(imageURI));

            $scope.imageURI = imageURI;

        }, function(err) {
            // error
            console.log("error: " + JSON.stringify(err));
        });

        $cordovaCamera.cleanup().then(
            function() {
                console.log("cleanup done");
            }); // only for FILE_URI
    };

我需要帮助才能让它在Android上运行 .

我已经在仿真器和真实设备上进行了测试 .

Cordova版本:5.4.1

emulator logcat输出如下:

--------- beginning of main
W/BindingManager( 2653): Cannot call determinedVisibility() - never saw a connection for the pid: 2653
--------- beginning of system
I/ActivityManager(  339): START u0 {act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras)} from uid 10057 on display 0
W/PluginManager( 2653): THREAD WARNING: exec() call to Camera.takePicture blocked the main thread for 264ms. Plugin should use CordovaInterface.getThreadPool().
D/ResolverActivity( 2562): sinceTime=1448829119611
I/ActivityManager(  339): START u0 {act=android.intent.action.GET_CONTENT cat=[android.intent.category.OPENABLE] typ=image/* flg=0x3000000 cmp=com.android.documentsui/.DocumentsActivity} from uid 10057 on display 0
W/EGL_emulation( 1929): eglSurfaceAttrib not implemented
W/OpenGLRenderer( 1929): Failed to set EGL_SWAP_BEHAVIOR on surface 0xa6742220, error=EGL_SUCCESS
I/Choreographer( 1929): Skipped 85 frames!  The application may be doing too much work on its main thread.
I/UsageStatsService(  339): User[0] Flushing usage stats to disk
I/ActivityManager(  339): Displayed com.android.documentsui/.DocumentsActivity: +5s48ms (total +5s807ms)
I/Choreographer( 1929): Skipped 122 frames!  The application may be doing too much work on its main thread.
W/IInputConnectionWrapper( 2653): showStatusIcon on inactive InputConnection
W/Documents( 1929): Failed to restore stack: java.io.FileNotFoundException: Failed to find matching root for null
D/Documents( 1929): Current stack: 
D/Documents( 1929):  * null
D/Documents( 1929): Before filtering 0, after 0
D/Documents( 1929): Before filtering 1, after 1
D/Documents( 1929): Found 2 of 2 recent queries done
I/art     ( 1929): Background partial concurrent mark sweep GC freed 1027(62KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 1752KB/2MB, paused 3.258ms total 114.968ms
W/AudioTrack(  339): AUDIO_OUTPUT_FLAG_FAST denied by client
D/Documents( 1929): onFinished() [content://com.android.providers.media.documents/document/image%3A25]
D/CordovaInterfaceImpl( 2653): Sending activity result to plugin
W/CordovaPlugin( 2653): Attempted to send a second callback for ID: Camera1798864042
W/CordovaPlugin( 2653): Result was: "content:\/\/com.android.providers.media.documents\/document\/image%3A25"
W/art     ( 2653): Attempt to remove local handle scope entry from IRT, ignoring
W/EGL_emulation( 2653): eglSurfaceAttrib not implemented
W/OpenGLRenderer( 2653): Failed to set EGL_SWAP_BEHAVIOR on surface 0xa00b1e20, error=EGL_SUCCESS
E/chromium( 2653): [ERROR:buffer_manager.cc(340)] [GroupMarkerNotSet(crbug.com/242999)!:7C04DEA1]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command
I/Choreographer(  339): Skipped 38 frames!  The application may be doing too much work on its main thread.
I/art     ( 1929): Explicit concurrent mark sweep GC freed 3277(230KB) AllocSpace objects, 0(0B) LOS objects, 24% free, 1554KB/2MB, paused 1.064ms total 312.134ms
I/art     ( 1929): Explicit concurrent mark sweep GC freed 701(63KB) AllocSpace objects, 3(68KB) LOS objects, 26% free, 1423KB/1935KB, paused 2.203ms total 296.900ms
I/art     ( 1929): Explicit concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 26% free, 1423KB/1935KB, paused 1.873ms total 404.704ms
E/StrictMode( 1929): class com.android.documentsui.DocumentsActivity; instances=2; limit=1
E/StrictMode( 1929): android.os.StrictMode$InstanceCountViolation: class com.android.documentsui.DocumentsActivity; instances=2; limit=1
E/StrictMode( 1929):    at android.os.StrictMode.setClassInstanceLimit(StrictMode.java:1)
I/Choreographer( 1929): Skipped 157 frames!  The application may be doing too much work on its main thread.

1 回答

相关问题