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
Developer
Posts: 223
Registered: ‎04-26-2012
My Device: Z10
My Carrier: Vodafone

opening file from mail invoke

Hi all!

 

I'm having some issues when trying to open an atached file on one email.

Invoke event is dispatched and uri is returned fine, but file seems to not exist:

 

 

var path:String=InvokeManager.invokeManager.startupRequest.uri;
trace(path);
path=path.replace("file://", "");
trace(path);
var f:File=new File(path);
trace(f.exists);

 Returns this traces:

 

file:///accounts/1000/invoke/com.xplota.playepub.app/xa00000000004d5/Robots%20and%20Empire%20-%20Isaac%20Asimov.epub

 

/accounts/1000/invoke/com.xplota.playepub.app/xa00000000004d5/Robots%20and%20Empire%20-%20Isaac%20Asimov.epub

 

false

 

So everything seems right but can't open the file because does not exists. I've tried unscaping path with same result.

How to deal with this?

 

My apps for Playbook: PlayEpub Book Reader with epub and FB2 support, Google Reader, ReaditLater - Net Files Share Explorer Get access to your network shared files- FFSync Sync your Firefox bookmarks and passwords
Developer
Posts: 223
Registered: ‎04-26-2012
My Device: Z10
My Carrier: Vodafone

Re: opening file from mail invoke

I've also tried reading that url stream, but does not work either:

 

var req:URLRequest = new URLRequest(url);
req.method = URLRequestMethod.GET;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, fetchComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, error);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorSecurity);
loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, httpStatus);
loader.load(req);

 

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: file:///accounts/1000/invoke/com.xplota.playepub.app/xa00000000004fe/Robots and Empire - Isaac Asimov.epub" errorID=2032]

My apps for Playbook: PlayEpub Book Reader with epub and FB2 support, Google Reader, ReaditLater - Net Files Share Explorer Get access to your network shared files- FFSync Sync your Firefox bookmarks and passwords
Developer
Posts: 223
Registered: ‎04-26-2012
My Device: Z10
My Carrier: Vodafone

Re: opening file from mail invoke

Any news from BB team?

My apps for Playbook: PlayEpub Book Reader with epub and FB2 support, Google Reader, ReaditLater - Net Files Share Explorer Get access to your network shared files- FFSync Sync your Firefox bookmarks and passwords
BlackBerry Development Advisor
Posts: 52
Registered: ‎04-01-2011
My Device: Torch, Playbook
My Carrier: Rogers

Re: opening file from mail invoke

Hi

 

are you sure that the unescape() call didn't work?

 

Using your code (the first one), I could see the errors when loading a file with spaces, and adding the unescape() call fixed it for me:

 

var path:String=InvokeManager.invokeManager.startupRequest.uri;
path = unescape(path);
trace(path);
path=path.replace("file://", "");
trace(path);
var f:File=new File(path);
trace(f.exists);

 Let's explore this solution. Maybe during your tests something else was going on. Could you try again using it?

 

Let me know how it goes.

 

Cheers

 

---
Paulo Garcia
Developer
Posts: 223
Registered: ‎04-26-2012
My Device: Z10
My Carrier: Vodafone

Re: opening file from mail invoke

To avoid unscaping issues I've tried with a new file without spaces...

This is the result with the same code, showing only traces:

 

URI received on invoke: file:///accounts/1000/invoke/com.xplota.playepub.app/xa0000000000205/quantum.epub
Path replaced for new File(path): /accounts/1000/invoke/com.xplota.playepub.app/xa0000000000205/quantum.epub
File exits: false

 

So everything seems right but file does not exist... Does it exist on your tests?

Tests are done on a real Z10, not simulator...

My apps for Playbook: PlayEpub Book Reader with epub and FB2 support, Google Reader, ReaditLater - Net Files Share Explorer Get access to your network shared files- FFSync Sync your Firefox bookmarks and passwords
BlackBerry Development Advisor
Posts: 52
Registered: ‎04-01-2011
My Device: Torch, Playbook
My Carrier: Rogers

Re: opening file from mail invoke

Hi,

 

I'm testing using a z10 as well. Could you please confirm the OS version you're testing with?

 

Also, see attached my test project, but I can't see anything different than whay you have.

 

Cheers

 

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

Re: opening file from mail invoke

When a file is saved and then invoked to another app, the file in the 'invoke/' path is not correct.  For example, I save a file in the download directory, send a notification, and when the notification is selected and the app is invoked, the request.uri that has 'invoke/' in the path, is not correct.  I have to:

 

////////////////////////////////////////////////////////////
private function appInvoked() : void
{
     var request : InvokeRequest = InvokeManager.invokeManager.startupRequest;
            

      if( request.target == "com.o2interactive.bike.rental.app" )
      {
          if( request.uri != null )this.invokeFile( request.uri );
      }     
}

////////////////////////////////////////////////////////
private function invokeFile( uri : String ) : void
{
            var file : File = new File( uri );
            
            // invoked from notification
            if( uri.indexOf( 'invoke' ) > 0 )
            {
                file = File.documentsDirectory.resolvePath( '../downloads/' + file.name );
            }

 Hope this helps.

Developer
Posts: 223
Registered: ‎04-26-2012
My Device: Z10
My Carrier: Vodafone

Re: opening file from mail invoke

OK, this is what happened.

Tried your proyect and same result, does not work.

 

After restarting the device everything works. So, thank you Smiley Happy

 

My apps for Playbook: PlayEpub Book Reader with epub and FB2 support, Google Reader, ReaditLater - Net Files Share Explorer Get access to your network shared files- FFSync Sync your Firefox bookmarks and passwords
Highlighted
BlackBerry Development Advisor
Posts: 52
Registered: ‎04-01-2011
My Device: Torch, Playbook
My Carrier: Rogers

Re: opening file from mail invoke

Jesus, glad to know everything is working. Restarting is not the solution I'd like to hear Smiley Happy, but if you see anything else, please let me know.

 

Cheers

 

 

---
Paulo Garcia