Android 使用相机拍摄图像后,照片不会返回到我的屏幕

Android 使用相机拍摄图像后,照片不会返回到我的屏幕,android,cordova,camera,sencha-touch-2,Android,Cordova,Camera,Sencha Touch 2,我正在尝试用相机捕捉图像,并用安卓系统将其显示在屏幕上。我使用sencha touch 2,phonegap来实现摄像头功能。它正在捕获图像,但不显示在屏幕上。 这是我的密码: 在仪表板面板文件中: { xtype : 'image', id : 'capturedimage', src : '', width : 60, height: 60, width : 200 }, {

我正在尝试用相机捕捉图像,并用安卓系统将其显示在屏幕上。我使用sencha touch 2,phonegap来实现摄像头功能。它正在捕获图像,但不显示在屏幕上。 这是我的密码:

在仪表板面板文件中:

{
        xtype : 'image',
        id : 'capturedimage',
        src : '',
        width : 60,
        height: 60,
        width : 200
 },
 {
        xtype : 'container',
        id : 'btncontainer',
        width : 120,
        layout : {
                   type : 'vbox'
              },
        items : [
        {
              xtype : 'button',
              height : 73,
              cls : 'capturebtn',
              id : 'capturebtn',
              width : 100
         },
         {
              xtype : 'button',
              height : 73,
              margin : '10 0 0 0',
              cls : 'choosephotobtn',
              id : 'selectphoto',
              width : 100
          } ]
   },
在控制器文件中::

onCaptureButtonTap: function(button, e, options) {
    /**
     *   phonegap Camera
     */

    navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true });  

       function onFail(message) {
           alert('Failed because: ' + message);
       }

       function onPhotoDataSuccess(imageData) {
           // Uncomment to view the base64 encoded image data
            console.log(imageData);

           // Get image handle
           //
           var smallImage = document.getElementById('capturedimage');

           // Unhide image elements
           //
           smallImage.style.display = 'block';

           // Show the captured photo
           // The inline CSS rules are used to resize the image
           //
           smallImage.src =  imageData;
         }

   }

但它不会到来。有谁能帮我一下吗?

这是因为我们现在默认使用getPicture中的文件URI返回类型。所以现在你只需要得到一个文件的url,而不是所有base64编码的数据。这是一种更好的方法,因为它不会占用太多内存。更改此行:

image = "data:image/jpeg;base64," + imageData;
致:


你应该准备好了。

伙计!!尝试在HTML img src=”“id=”“上设置图像,您将在屏幕上看到该图像

最后,我可以使用以下链接解决此问题:


我不是Sencha专家,因此为了确保PG部件正常工作,请执行console.log(imageData)在onPhotoDataSuccess方法中,我们可以确保它被正确调用。您是否在
adb logcat
输出中看到任何错误?不,它没有给出任何logcat错误..您是否检查了@Simon的最后一条注释以打印successs的输出现在它进入了onFail方法中,它得到了什么消息?如何做..i编辑代码。当我在控制台中打印它时,它会给我base64编码的图像数据。如下所示:07-23 12:25:55.015:I/Web控制台(7215):content://media/external/images/media/125 电话:899934341
image.src = imageData;