phonegap原生android应用程序问题

时间:2014-02-12 11:15:22

标签: android html5 jquery-mobile cordova

您好我正在开发一个原生Android应用程序在手机间隙,在该应用程序中我想通过选择文件按钮上传图像文件当我点击按钮我想打开设备库但画廊窗口没有打开。当我通过设备中的浏览器加载时我可以打开图库窗口,但是无法将其原生于android,所以请帮我找到解决方案。

手机间隙脚本文件是否会针对各种平台进行更改,或者需要为手机间隙中的各种平台添加任何插件文件,或者我需要将任何 cordova.js 文件添加到根文件中(例如WWW)。

我怀疑手机间隙或设备中的任何版本兼容性问题所以请帮助我。

有关详细信息,我将在下面添加我的代码。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
  <link rel="stylesheet" type="text/css" href="css/style.css" />
  <link rel="stylesheet" type="text/css" href="js/jquery/plugins/jqtransform/jqtransform.css" />
  <title> Mobile</title>
  <script src="js/jquery/jquery162min.js" type="text/javascript"></script>
  <script src="js/jquery/plugins/accordion/jqueryui1814custommin.js" type="text/javascript"></script>
  <script type="text/javascript" src="js/jquery/plugins/jqtransform/jqtransform.js" ></script>
  <script src="js/mgeneral.js" type="text/javascript"></script>
  <script src="../js/pl/plupload.js" type="text/javascript"></script>
  <script src="../js/pl/plupload.html5.js" type="text/javascript"></script>

 <script type="text/javascript" language="javascript">
$(document).ready(function () {
    /*Set skin for select, options and checkbox*/
    $('.skinnable').jqTransform({ imgPath: 'img/' });

    $('#apply-to-selection-2').click(function (e) {
        e.preventDefault();
        Logout();
        if (RTNCODE)
            window.location = "index.html";

    });

    /*table row select*/
    $("table.grid thead tr th.col-row-select input").click(function () {
        if (!$(this).is(":checked")) {
            $("table.grid tbody tr td.col-row-select input").each(function () {
                $(this).attr("checked", true);
                $(this).change();
            });
        }
        else {
            $("table.grid tbody tr td.col-row-select input").each(function () {
                $(this).attr("checked", false);
                $(this).change();
            });
        }
    });
    /*END table row select*/
    /*Create accordion*/
    $(".accordion").accordion({
        header: ".accordion-tab",
        collapsible: true,
        active: 0,
        autoHeight: false
    });

});
    </script>

    <script type="text/javascript">

     $(function () {  //image loader
         var uploaderimage = new plupload.Uploader({
             // General settings
             runtimes: 'html5',
             container: 'imagecontainer',
             browse_button: 'pickfiles',
             url: '/imageupload.ashx?mobile=true',
             multi_selection: false,
             max_file_size: '10mb',
             //chunk_size: '1mb',
             multipart: true,
             urlstream_upload: true,
             // Specify what files to browse for
             filters: [
                             { title: "Image files", extensions: "jpg,gif,png" }
             ]


         });

         uploaderimage.init();


         uploaderimage.bind('FilesAdded', function (up, files) {
             //            showmodalmask();
             uploaderimage.start();
             $('.imgpre').show();
             $('.imgcpl').hide();
         });

         uploaderimage.bind('FileUploaded', function (up, file) {
             if (uploaderimage.total.uploaded == uploaderimage.files.length) {
                 //            $('.btnrefresh').click();
                 $('.imgcpl').show();
                 $('.imgpre').hide();
              }
          });
       });
    </script>
 </head>

 <body>
  <div class="container">
   <div class="frame">
    <div class="frame-border-top"></div>
     <div class="frame-border-middle">
      <div class="cute" style="">
        <h1 class="header" style="color:transparent; width:270px; height:20px;">
  </h1></div>
  <!-- MENU  START  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->

  <div id="tabs-2" style="background-color:Black; border:1px solid #363636;">
        <div style="margin-left:-15px; margin-top:-6px;">
            <div class="form-row padding-lr-5" style="text-align:center;">
              <div id="imagecontainer" >

                <div id="filelist"></div>

                <br />

                <a id="pickfiles" href="#" style="background-color: #447cd1; color: white; border: 2px solid #113b7c; border-radius: 12px; padding: 6px 10px; font-size: 12pt; text-decoration: none">Select file</a>

            </div>
                <br />
                <div class="holderloderp imgpre" style="display:none"><img src="../images/pnl-preloader2.gif" width="25" height="25" alt="" class="pnl-preloader2" /></div>
                <div class="imgcpl" style="color: green; display: none" >Complete</div>
            </div>
              <div class="clear" style="height:25px;"></div>
            </div>
          </div>
        </div>
      </div>
    </div>   
  </div>
 </div>

 

1 个答案:

答案 0 :(得分:0)

您需要使用phonegap API的FileTransfer对象,该对象将使用任何服务器端脚本文件处理程序上传到您的服务器。

Look at this link