In PhoneGap 2.8.0 for Android:
I need to get an image from the phone gallery And I need it in the app ...
My code: Head: HTML: script : But this is not working ... How can I do this? The error that I found in the console file: ///android_asser/www/index.html: Uncaught TypeError: There is no method 'split' [object Object]: properties undefined Uncaught can not read 'PHOTOLIBRARY' of TypeError the file: ///android_asset/www/js/jquery.mobile-1.0rc1.min.js After jquery and jquery-mobile it is working ... jQuery with phonegap with any problem? In advance thanks I have implemented this code ..recently .check this my html
& lt; Meta name = "viewport" content = "width = device-width, initial-scale = 1" /> & Lt; Link rel = "stylesheet" href = "css / jquery.mobile-1.0rc1.min.css" /> & Lt; Link rel = "stylesheet" href = "css / styles.css" /> & Lt; Script src = "js / jquery.js" & gt; & Lt; / Script & gt; & Lt; Script src = "js / jquery.mobile-1.0rc1.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "js / cordova.js" & gt; & Lt; / Script & gt;
& lt; Button data subject = "D" onclick = "getPhoto (pictureSource.PHOTOLIBRARY);" & Gt; Browse photos & lt; / Button & gt; & Lt; Div id = "photos" & gt; & Lt; / Div & gt;
function onPhotoURISuccess (imageURI) {var img = $ ( '& lt; img / & gt; '); Img.attr ('src', imageURI); Img.appendTo ('# photos'); }
& lt; Script type = "text / javascript" charset = "utf-8" src = "cordova.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" charset = "UTF-8" & gt; Var pictureSource; Var destination type; Document.addEventListener ("deviceready", onDeviceReady, false); Function OnDevice Read () {pictureSource = navigator.camera.PictureSourceType; DestinationType = navigator.camera.DestinationType; } Function to function (imageURI) {console.log (imageURI); Var bigImage = document.getElementById ('big image'); BigImage.style.display = 'block'; BigImage.src = imageURI; } Function on FootDataSus (imageURI) {var imgProfile = document.getElementById ('imgProfile'); ImgProfile.src = imageURI; If (sessionStorage.isprofileimage == 1) {getLocation (); } Driver text (imageURI); } File (message) on function {warning ('failed because:' message); } Function Hillpack (file) {window.resolveLocalFileSystemURI (File, Solution onsvv, resOnError); } Function resolution onsite (entry) {var d = new date (); Var n = d.getTime (); Var newFileName = n + ".jpg"; Var myFolderApp = "MyAppFolder"; window.requestFileSystem (LocalFileSystem.PERSISTENT, 0, function (fileSys) {fileSys.root.getDirectory (myFolderApp, create {Really Exclusive: false}, function (index) {entry.moveTo (directory, newFileName, successMove, resOnError); }, ResOnError);}, resOnError); } Function successMove (entry) {sessionStorage.setItem ('imagepath', entry.fullPath); } Function resOnError (error) {warning (error.code); } Function capturePhotoEdit () {navigator.camera.getPicture (onPhotoDataSuccess, onFail, {quality: 20, allowEdit: True, destinationType: destinationType.DATA_URL}); } Function getPhoto (source) {navigator.camera.getPicture (Prfotoirisuves, Onfail, {quality: 50, destination types: Gantwytaip. FILE_URI, Source Type: Source}); } & Lt; / Script & gt;
& lt; Button onclick = "capturefoto ();" & Gt; Capture photo & lt; / Button & gt; & Lt; Button onclick = "getPhoto (Image Source.PHOTOLIBRARY);" & Gt; From gallery !! & Lt; / Button & gt;
No comments:
Post a Comment