Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Highlighted
Regular Contributor
Posts: 94
Registered: ‎04-07-2011
My Device: PlayBook
My Carrier: QED
Accepted Solution

navigateToURL , app / app-storage dirs : What's The Problem?

I'm trying to use flash.net.navigateToURL to open the browser to display an HTML file that is located in the application directory (or the application-storage directory, if necessary). Neither of the following two approaches work...

 

// (1)
	var target:File = File.applicationDirectory.resolvePath(filename);
	navigateToURL(new URLRequest(target.url));
// (2)
	var target:File = File.applicationStorageDirectory.resolvePath(filename);
	navigateToURL(new URLRequest(target.url));

 

The PlayBook browser is opened, the HTML content is not displayed, but the following error message is:

 

"This file could not be opened. Check that you have the correct permissions and try again."

 

(http:// URLs work fine, but I haven't been able to get local files in either the app or app-storage directories to work using the above approaches, or using native path discrimination, etc.)

 

Any ideas, or functioning code? (I'm running OS 2.0.1.358, BTW.)

 

Developer
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: navigateToURL , app / app-storage dirs : What's The Problem?

The error message says it all...

 

On PlayBook, apps are sandboxed. One app cannot access another apps files. The browser is an app too. It can't access the files in the private area of your app. That would cause all sorts of security problems.

 

Solutions: either copy your .html to a public folder somewhere, or embed a StageWebView in your app and load the page into that.

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Regular Contributor
Posts: 94
Registered: ‎04-07-2011
My Device: PlayBook
My Carrier: QED

Re: navigateToURL app/app-storage - What's The Problem?

Well, Innovatology, you have confirmed my suspicion, although I suppose one could argue that system software (eg., navigateToURL) could / should support an application programmatically invoking the browser app c/w a URL to one of _its_own_ local files without compromizing security.

 

The security constraint that you've described would seem to require the use of "access_shared" for the public folder approach.

 

The second approach - StageWebView - I used in my first app for the PlayBook. It does provide a seemless user experience, relative to browser invocation, however even when reusing extant code it's the more onerous solution.

Regular Contributor
Posts: 94
Registered: ‎04-07-2011
My Device: PlayBook
My Carrier: QED

Re: navigateToURL app/app-storage - What's The Problem?

er, "seamless".
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: navigateToURL app/app-storage - What's The Problem?

Security is security. You can embed the web view to see if that is what you are looking for. This has been an issue for sometime.
Developer
Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: navigateToURL , app / app-storage dirs : What's The Problem?

I have a PDF and I am packaging it with my app....

 

Dir Structure
 

/src

-file.pdf


My understanding is I have to copy the pdf file into a shared folder to access it via Adobe Reader.

 

Question:

How do I do this? 

Any sample code would be greatly appreciated. This will save me 2 days time to figure out. 

 

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: navigateToURL , app / app-storage dirs : What's The Problem?

You wish is my command...

var local:File = File.applicationDirectory.resolvePath( 'usersguide.pdf' );
var open :File = File.documentsDirectory.resolvePath( '../misc/MyAppNameUsersGuide.pdf' );
if( local.exists )
{
                local.copyTo( open, true );
                open.openWithDefaultApplication();
}

 

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: navigateToURL , app / app-storage dirs : What's The Problem?

If you are attending JAM10, you may wish to attend DEV117 session that will cover some of this and more.
Developer
Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: navigateToURL , app / app-storage dirs : What's The Problem?

I cannot affort BB10 Jam atm. Your solution worked.

 

THANK YOU jtegen

Developer
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: navigateToURL app/app-storage - What's The Problem?


Transcendental_Mobile wrote:

Well, Innovatology, you have confirmed my suspicion, although I suppose one could argue that system software (eg., navigateToURL) could / should support an application programmatically invoking the browser app c/w a URL to one of _its_own_ local files without compromizing security.


Consider this:

 

  • user opens the browser from your app to display an html located in the sandbox
  • user removes the filename from the url and lists all the files
  • user navigates up a folder or two
  • user downloads your .swf
  • user repackages your swf and posts it online

Oops...

 

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands