Skip to content
Browse files

Updated invocations to automatically load a PNG file to shared/downlo…

…ads that will be used to invoke Pictures
  • Loading branch information...
1 parent 811d206 commit 6acdc151f3310e787c19d712205ed8338920e763 @haahmad haahmad committed Jun 25, 2012
View
BIN invoker/HTML5_Logo_512.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3 invoker/config.xml
@@ -10,5 +10,8 @@
email = "author@rim.com">Research In Motion Ltd.</author>
<description>This app demonstrates how to invoke applications.</description>
<rim:orientation mode="portrait" />
+ <rim:permissions>
+ <rim:permit>access_shared</rim:permit>
+ </rim:permissions>
<feature id="blackberry.invoke" required="true" version="1.0.0.0"/>
</widget>
View
BIN invoker/device/invoker.bar
Binary file not shown.
View
2 invoker/index.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1">
<script src="webworks-1.0.0.7.js"></script>
<script src="invocations.js"></script>
<link rel="stylesheet" type="text/css" href="/jquery.mobile-1.1.0.min.css" />
View
66 invoker/invocations.js
@@ -50,7 +50,71 @@ function invokeApp() {
}
function invokePictures() {
+
+ downloadPicture();
+
blackberry.invoke.invoke({
- uri: "file:///accounts/1000/shared/downloads/HTML5.png",
+ uri: "file:///accounts/1000/shared/downloads/HTML5_Logo_512.png",
}, onSuccess, onError);
}
+
+function downloadPicture() {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', "/HTML5_Logo_512.png", true);
+ xhr.responseType = 'arraybuffer';
+
+ xhr.onload = function(e) {
+ if (this.status == 200) {
+ var bb = new window.WebKitBlobBuilder();
+ bb.append(this.response);
+ var blob = bb.getBlob('image/png');
+ saveFile(blob);
+ }
+ };
+ xhr.send();
+}
+
+function saveFile (blob) {
+ function gotFs(fs) {
+ fs.root.getFile("/accounts/1000/shared/downloads/HTML5_Logo_512.png", {create: true}, gotFile, errorHandler);
+ }
+
+ function gotFile(fileEntry) {
+ fileEntry.createWriter(gotWriter, errorHandler);
+ }
+
+ function gotWriter(fileWriter) {
+ fileWriter.onerror = function (e) {
+ alert("Failed to write PNG: " + e.toString());
+ }
+ fileWriter.write(blob);
+ }
+ window.webkitRequestFileSystem(PERSISTENT, 10 * 1024, gotFs, errorHandler);
+}
+
+function errorHandler(e) {
+ var msg = '';
+
+ switch (e.code) {
+ case FileError.QUOTA_EXCEEDED_ERR:
+ msg = 'QUOTA_EXCEEDED_ERR';
+ break;
+ case FileError.NOT_FOUND_ERR:
+ msg = 'NOT_FOUND_ERR';
+ break;
+ case FileError.SECURITY_ERR:
+ msg = 'SECURITY_ERR';
+ break;
+ case FileError.INVALID_MODIFICATION_ERR:
+ msg = 'INVALID_MODIFICATION_ERR';
+ break;
+ case FileError.INVALID_STATE_ERR:
+ msg = 'INVALID_STATE_ERR';
+ break;
+ default:
+ msg = 'Unknown Error';
+ break;
+ };
+
+ alert('Error: ' + msg);
+}
View
BIN invoker/invoker.zip
Binary file not shown.
View
BIN invoker/simulator/invoker.bar
Binary file not shown.

0 comments on commit 6acdc15

Please sign in to comment.
Something went wrong with that request. Please try again.