相关疑难解决方法(0)

从assets/www目录访问文件

假设foo.html我的assets/www目录(我的index.html旁边)有一个名为sitting(非常舒服)的文件.

我想将该文件复制到设备上的其他位置.我的第一种方法window.resolveLocalFileSystemURI("foo.html", cool(), notCool());不起作用.还有一个像www /它的前缀它不会.

知道它是否真的可以通过Phonegap访问文件会很有趣.我不相信,因此希望看到一个代码片段如何获取资产目录中的文件的FileEntry - 如果可能的话.

编辑:好的,现在我们有这样的电话

window.resolveLocalFileSystemURI("file:///android_asset",
  function(entry){
    console.log(entry.fullPath);},
  function(evt){
    console.log(evt.code);}
);
Run Code Online (Sandbox Code Playgroud)

但我们得到了一个错误code: undefined(Phonegap v1.2)和code: 1v1.0(代码1 =找不到文件?!)

android cordova

14
推荐指数
2
解决办法
2万
查看次数

使用phonegap从相机或图库中选择图像

<script type="text/javascript" charset="utf-8">



var pictureSource;   // Picture source

var destinationType; // Sets the format of returned value 

// Wait for PhoneGap to connect with the device


document.addEventListener("deviceready", onDeviceReady, false);


// PhoneGap is ready to be used!

function onDeviceReady() 

{


   pictureSource = navigator.camera.PictureSourceType;

    destinationType = navigator.camera.DestinationType;


}

function capturePhoto() {

    navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 25, destinationType: 
Camera.DestinationType.FILE_URI });

}

function onPhotoURISuccess(imageURI) {

    createFileEntry(imageURI);
}

function createFileEntry(imageURI) {

    window.resolveLocalFileSystemURI(imageURI, copyPhoto, fail);    
}

function copyPhoto(fileEntry) {

    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) { 
        fileSys.root.getDirectory("photos", {create: true, …
Run Code Online (Sandbox Code Playgroud)

android jquery-mobile cordova

5
推荐指数
1
解决办法
3800
查看次数

使用离子框架从android中的图库中显示图像

你好我正在尝试开发Android应用程序来加载图像库中的图像.这是代码snipet.我无法显示图像.有人可以指出我哪里出错了吗?

*.html的

<ion-view title="Account">
  <ion-content class="has-header padding">
    <h1>Upload Image</h1>
      <div class="account-picture">
          <button ng-click="ShowPictures()">Select Picture</button>
          <img src="ImageURI" id="smallimage">
          <input type="text" ng-model="ImageURI" size="30"/>
      </div>
  </ion-content>
</ion-view>
Run Code Online (Sandbox Code Playgroud)

Controller.js

.controller('AccountCtrl', function($scope) {

    $scope.ImageURI = 'Select Image';
    function UploadPicture(imageURI) {

        $scope.ImageURI =  imageURI;
        alert($scope.ImageURI );
    }

    $scope.ShowPictures = function() {
        navigator.camera.getPicture(UploadPicture, function(message) {
                alert('get picture failed');
            }, {
                quality: 50,
                destinationType: navigator.camera.DestinationType.FILE_URI,
                sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
            }
        );
    };
});
Run Code Online (Sandbox Code Playgroud)

在这里ia ImageURI我正在接收afetr从图库中选择任何文件:content:// media/external/images/media/17.我盲目地为我的图像src硬编码了这个值.但我没有看到任何.这里有什么输入?

此外,ImageURI也没有绑定我的文本框.警报正确显示URI.

它看起来非常直接使用普通的phonegap应用程序.但我不喜欢离子框架.

phonegap-plugins cordova ionic-framework

5
推荐指数
1
解决办法
9329
查看次数