Comments (24)
FileReader is not implemented so there's no way to read files
Original comment by [email protected]
on 21 Sep 2011 at 3:48
from gwt-phonegap.
you are right, fix will be in trunk soon
Original comment by [email protected]
on 21 Sep 2011 at 5:18
- Changed state: Accepted
from gwt-phonegap.
Will you implement FileReader also?
Original comment by [email protected]
on 21 Sep 2011 at 5:58
from gwt-phonegap.
yes sure
Original comment by [email protected]
on 21 Sep 2011 at 6:08
from gwt-phonegap.
fix is in trunk, but I havent had time to test anything yet. Testing and a Mock
API for hosted mode will be done soon. Hope that premature fix helps.
I leave the issue open until proper testing is done.
Original comment by [email protected]
on 21 Sep 2011 at 6:32
from gwt-phonegap.
Trying to use it but having some problem figuring out how to use the
FileReader. Here's my code:
phoneGap.getFile().requestFileSystem(File.LocalFileSystem_PERSISTENT, 0, new
FileCallback<FileSystem, FileError>() {
public void onSuccess(FileSystem entry) {
if (entry != null) {
Flags f = new Flags();
f.setCreate(true);
entry.getRoot().getFile("file.txt", f, new FileCallback<FileEntry, FileError>() {
public void onSuccess(FileEntry entry) {
// the following contructor is protected but I would assume that's how it
should be used?
FileReader fr = new FileReaderJsImpl();
fr.setOnLoadEndCallback(new ReaderCallback<FileReader>() {
public void onCallback(FileReader result) {
String content = result.getResult();
}
});
fr.readAsText(entry);
}
public void onFailure(FileError error) {
throw new UnsupportedOperationException("Not supported yet.");
}
});
}
}
public void onFailure(FileError error) {
throw new UnsupportedOperationException("Not supported yet.");
}
});
Original comment by [email protected]
on 22 Sep 2011 at 7:35
from gwt-phonegap.
you can`t instanciate FileReaderJsImpl its a javascript overlay class
Use the createReader on the File module:
phoneGap.getFile().createReader();
You can also simualte the phonegap file api in dev mode now, but you need to
start your jvm with -DinsecurePhoneGapFileApi=true -DphonegapFilePath="<the
directory to use" (note: jvm options not gwt hosted mode options). I will write
up some documentation on how to use it soon (its not quite finished yet)
in the trunk theres an example how to use it:
http://code.google.com/p/gwt-phonegap/source/browse/gwt-phonegap-showcase/src/ma
in/java/de/kurka/phonegap/showcase/client/file/FilePresenter.java
Original comment by [email protected]
on 22 Sep 2011 at 3:17
from gwt-phonegap.
The following code is yielding a "[INFO] Error in success callback:
com.phonegap.file1 = RangeError: Maximum call stack size exceeded" - it fails
somewhere in the onSuccess(FileEntry entry)
phoneGap.getFile().requestFileSystem(File.LocalFileSystem_PERSISTENT, 0, new
FileCallback<FileSystem, FileError>() {
public void onSuccess(FileSystem entry) {
console("got fs: "+entry);
if (entry != null) {
Flags f = new Flags();
f.setCreate(true);
entry.getRoot().getFile(filename, f, new FileCallback<FileEntry, FileError>() {
public void onSuccess(FileEntry entry) {
console("got fs2: "+entry);
FileReader fr = phoneGap.getFile().createReader();
fr.setOnLoadEndCallback(new ReaderCallback<FileReader>() {
public void onCallback(FileReader result) {
console("got fs3: "+result);
String content = result.getResult();
console("login file found: " + content);
callback.onSuccess(content);
}
});
fr.readAsText(entry);
}
public void onFailure(FileError error) {
console("failed1");
throw new UnsupportedOperationException("Not supported yet.");
}
});
}
}
public void onFailure(FileError error) {
console("failed2");
throw new UnsupportedOperationException("Not supported yet.");
}
});
console:
2011-09-23 10:26:38.133 CM[1904:f503] [INFO] got fs2:
de.kurka.phonegap.client.file.js.FileEntryJsImpl@1f
2011-09-23 10:26:38.135 CM[1904:f503] [INFO] Error in success callback:
com.phonegap.file1 = RangeError: Maximum call stack size exceeded.
Original comment by [email protected]
on 23 Sep 2011 at 8:33
from gwt-phonegap.
I have a feeling that readAsText is recursively calling itself in your code.
Original comment by [email protected]
on 23 Sep 2011 at 8:45
from gwt-phonegap.
make sure that you have got the latest version. I had the same issue yesterday
and fixed it in trunk
Original comment by [email protected]
on 23 Sep 2011 at 8:49
from gwt-phonegap.
Ok confirmed, funtion readAsText was calling itself. Here's the fix:
@Override
public void readAsText(FileEntry entry) {
FileEntryJsImpl entryJs = (FileEntryJsImpl) entry;
readAsText(entryJs.getEntry());
}
Original comment by [email protected]
on 23 Sep 2011 at 9:00
from gwt-phonegap.
take a look at trunk should be fine now:
http://code.google.com/p/gwt-phonegap/source/browse/gwt-phonegap/src/main/java/d
e/kurka/phonegap/client/file/js/FileReaderJsImpl.java
Original comment by [email protected]
on 23 Sep 2011 at 9:10
from gwt-phonegap.
Yes it works
Original comment by [email protected]
on 23 Sep 2011 at 1:28
from gwt-phonegap.
Not sure why but it seems that getFile() in the following, returns null (on
Android emulator). Permissions are set, SD is available but it still returns
null:
phoneGap.getFile().requestFileSystem(File.LocalFileSystem_PERSISTENT, 0, new
FileCallback....
Original comment by [email protected]
on 23 Sep 2011 at 2:01
from gwt-phonegap.
it seems fine to me on android emulator. can you provide a bigger code sample
for me to run?
Original comment by [email protected]
on 24 Sep 2011 at 9:22
from gwt-phonegap.
[deleted comment]
from gwt-phonegap.
This code fails in FileJsImpl's requestFileSystem (right after
$wnd.requestFileSystem is called). callback functions are never called:
phoneGap.getFile().requestFileSystem(File.LocalFileSystem_PERSISTENT, 0, new FileCallback<FileSystem, FileError>() {
public void onSuccess(FileSystem entry) {
console("got fs: " + entry);
if (entry != null) {
Flags f = new Flags();
f.setCreate(false);
entry.getRoot().getFile(filename, f, new FileCallback<FileEntry, FileError>() {
public void onSuccess(FileEntry entry) {
console("got fs2: " + entry);
FileReader fr = phoneGap.getFile().createReader();
fr.setOnLoadEndCallback(new ReaderCallback<FileReader>() {
public void onCallback(FileReader result) {
console("got fs3: " + result);
String content = result.getResult();
callback.onSuccess(content);
}
});
console("reader created");
fr.readAsText(entry);
}
public void onFailure(FileError error) {
console("login file does not exist");
callback.onSuccess(null);
}
});
}
}
public void onFailure(FileError error) {
console("failed2");
throw new UnsupportedOperationException("Not supported yet.");
}
});
Original comment by [email protected]
on 27 Sep 2011 at 12:33
from gwt-phonegap.
Upgraded to latest gwt-phonegap, using phonegap 1.0.0 - the above will throw
the following error in Android only, works fine with iOS:
(TypeError): Result of expression '$wnd.requestFileSystem' [undefined] is not a function
Original comment by [email protected]
on 30 Sep 2011 at 9:38
from gwt-phonegap.
seems like you missing the phonegap.js file for some reason.
can you post your html host file for your device?
can you post your bootup code in gwt for starting gwt-phonegap?
Original comment by [email protected]
on 30 Sep 2011 at 9:59
from gwt-phonegap.
Well phonegap is loading properly because void
onPhoneGapAvailable(PhoneGapAvailableEvent event) is called just fine after
phoneGap.initializePhoneGap();
Remember this works fine in iOS just not Android.
I have <script src="./phonegap-1.0.0.js" type="text/javascript"
charset="utf-8"></script>
and
<meta name='gwt:module' content='com.mobile=com.mobile'/>
in <Head>
Also
<iframe src="javascript:''" id='__gwt_historyFrame' style='width:0;height:0;border:0'></iframe>
<script type="text/javascript" src="./com.mobile/com.mobile.nocache.js"></script>
first thing in <body>
Original comment by [email protected]
on 2 Oct 2011 at 7:24
from gwt-phonegap.
What kind of phone are you using?
I can`t seem to be able to reproduce this with any android phone I have got
Original comment by [email protected]
on 2 Oct 2011 at 6:59
from gwt-phonegap.
Using emulators (2.2 & 3.x)
Original comment by [email protected]
on 3 Oct 2011 at 5:58
from gwt-phonegap.
I have tried to replicate the problem with the trunk and an android 2.2
emulated device.
My onFailure function is called just fine with PERMISSION_DENIED.
can you put some javascript into your page to alert the value of
window.requestFileSystem ?
It this is null or not a function something is fishy with your setup for android
Original comment by [email protected]
on 4 Oct 2011 at 8:45
from gwt-phonegap.
I will close this off since there hasn`t been any feebback for more than 6
months
Original comment by [email protected]
on 30 Apr 2012 at 5:46
- Changed state: Done
from gwt-phonegap.
Related Issues (20)
- Patch for /src/main/java/com/googlecode/gwtphonegap/client/globalization/js/LanguageJsImpl.java HOT 4
- "readAsBinaryString()" and "readAsArrayBuffer()" not yet supported HOT 1
- Module Camera : MediaType isn't working HOT 1
- ConnectionMobileImpl deprecated method call navigator.network.connection HOT 3
- Memory leak while detecting network connection. HOT 2
- Not compatible with Phonegap 3.0 HOT 6
- Project page displays wrong Phonegap and GWT versions HOT 1
- PhoneGapStandardImpl fails in Internet Explorer 8 (IE8)
- issue on ipad when mailto special character
- onPhoneGapAvailable() never called when upgraded to PG 3.3 HOT 2
- create FileWriter with the append flag HOT 1
- FileReader#readAs* methods should accept File instead of FileEntry HOT 5
- gwt-phonegap 3.5 downloads not available in downloads on http://code.google.com/p/gwt-phonegap
- Add a direct install linker to enable nativ calls at startup
- Support several options available while opening an InApp browser HOT 1
- gwt-phonegap to detect missing plugins and handle error nicely HOT 2
- MainResourceHolder moved Package, ShowMasterEvent no longer exists, POM needs updating, Annotation errors
- misspelling in FileTransferJsImpl leads to broken (unset) headers HOT 1
- resolveLocalFileSystemURI is deprecated. Please call resolveLocalFileSystemURL instead. HOT 1
- Add support for Cordova 4.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gwt-phonegap.