Reputation: 1591
Im using flash builder 4.6 and flex 4.12.1 sdk and have a routine where Im using the DISTRIQT camera ANE to take a photo, adding it to the UI as a bitmap image, using BYTEARRAY to save that new image to the application documentsDirectory... I am then trying to use navigateToURL to open that image in either the default web browser or any installed application the user chooses (the latter of which is the preferred solution, but the former will suffice)... I wish I could use as3's openWithDefaultApplication() but its not available on AIR mobile sdk.
I can confirm the file is saved and the path to it is accurate -- so the file is where it should be ... I have the following trace statements triggered by an event listener to help aid in verifying the files existence and location / path:
trace('exists? ' + targetFile.exists); // shows console message -- exists? true
trace('the url: ' + targetFile.url); // shows console message -- the url: trace('path: ' +
targetFile.nativePath); // shows console message -- path: /storage/sdcard0/test.jpg
RESULTS from my tests:
1.) HTC One, running android 4.4.2 -- works and opens the jpg in native web browser just fine. 2.) Older Galaxy S II running android 4.1.2 -- creates image but never opens browser and no error message 3.) ios 7.1.2 on an iphone 4S -- the image is created, but the local url never loads in browser at all
to try to load the file Im using the following:
var targetFile : File = File.documentsDirectory.resolvePath('test.jpg');
var targetURL2: String = targetFile.url;
navigateToURL( new URLRequest( targetURL2 ));
Basically, my question is: is there a reliable simple way to load a document (html or specifically in this case, jpg) that stored locally in the applicationDocumentsDirectory?
What am I overlooking or misunderstanding about either navigatetourl or accessing files in the documentsDirectory?
Upvotes: 0
Views: 765
Reputation: 369
You might need to add a "protocol-header" to your URL like "file:///" (Yes, three slashes;-) )
Read more about it in the AIR docs
If you need a user dialog, you will need to implement a native extension, though. I once found a tutorial, doing a native "send-to" dialog in Android and iOS, which is basically the same. Sorry, but I don't have the link at hand right now.
Upvotes: 2