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
New Contributor
Posts: 3
Registered: ‎02-10-2011
My Device: Not Specified
Accepted Solution

user starts up the application by clicking a file

[ Edited ]

I'm trying to do an unzip like application for the Blackberry Playbook, which means that the application mostly gets launched when the user clicks a file for which the app is registered.

 

I googled a bit around, and the closed what I found is this, but MobileApplication doesn't have invoke parameter.

 

 

<?xml version="1.0" encoding="utf-8"?>
<s:MobileApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                     xmlns:s="library://ns.adobe.com/flex/spark" firstView="views.TestHome"
                     invoke="onAppInvoke(event)">
    <fx:Declarations>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            private function onAppInvoke(event:InvokeEvent):void {
                if (event.arguments.length>0) {
                    // ok app call with an arguments
                    var fileName:String=event.arguments[0];
                    trace("app open with : "+fileName);
                } else {
                    // app open normally
                    trace("normal launch");
                }
            }
        ]]>
    </fx:Script>
</s:MobileApplication>

 

 

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

Re: user starts up the application by clicking a file

This might be a problem because the PB does not have a current way to just browse the file system and select a file to open.  True, you can associate file types to a particular application (in AIR), but none of that is known to be available in the PB.

 

It might be better to run your application and then browse possible files from the standard system directories where the user will place files.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: user starts up the application by clicking a file

[ Edited ]

I don't use MXML or MobileApplication, but maybe this will help.

 

The NativeApplication object will issue an InvokeEvent so perhaps you can just listen for it.  In a pure AS3 app it is sent on the PlayBook.

 

Now, whether it is of any use is another story.  There has been nothing published by QNX/RIM about whether this will be involved in the mechanism used to launch "default" apps for files, nor in fact whether that will even be possible.  We assume it will be, of course, but I believe anyone talking about this would just be guessing as to how and even whether it will actually work.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Contributor
Posts: 3
Registered: ‎02-10-2011
My Device: Not Specified

Re: user starts up the application by clicking a file

Thx for your answers! Hooking it up to NativeApplication is the solution.

 

But both of you are right about the general file handling of the PB. I registered the file type, installed & run the app and tried to open a file over the Browser, but nothing happens.

 

I can't imagine that the final version can have such limitation, with e-mail attachments, internet downloads and so on.

 

Here the code:

 

<?xml version="1.0" encoding="utf-8"?>
<s:MobileApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                     xmlns:s="library://ns.adobe.com/flex/spark" firstView="views.TestHome"
                     applicationComplete="myAppMain()">
    <fx:Declarations>

    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            private function myAppMain():void {
                NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onAppInvoke);
            }

            private function onAppInvoke(event:InvokeEvent):void {
                if (event.arguments.length>0) {
                    // ok app call with an arguments
                    var fileName:String=event.arguments[0];
                    trace("app open with : "+fileName);
                } else {
                    // app open normally
                    trace("normal launch");
                }
            }
        ]]>
    </fx:Script>
</s:MobileApplication>

 

 

 

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

Re: user starts up the application by clicking a file

[ Edited ]

From what I've seen, the PB is application-centric not file-centric.  If something (an application) is downloading a file, then it will be responsible for that file.  I'm not certain if the PB will allow "save as" on things arbitrarily (like in a browser).  Things like email attachments, other than PDF files there has been no discussions or published procedures or API to manage the launch or file mapping to other applications.

 

The PB is not trying to be a laptop or desktop computer.  But, interoperability between apps in terms of files and protocols would be very helpful.  I just don think we're there yet.

New Contributor
Posts: 3
Registered: ‎02-10-2011
My Device: Not Specified

Re: user starts up the application by clicking a file

I made a feature request for it...

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

Re: user starts up the application by clicking a file

What ever your application plans are, dont wait around for the feature request to be implemented (unless it has and we just dont know about it).  I've seen many systems get developed, and inter-operability (protocol, live data exchange (cut/paste/stream/pub-sub), unified data storage, etc) are typically the last things considered and then they try to back fit it.  And the result is rarely clean.

Developer
Posts: 382
Registered: ‎05-19-2008
My Device: BlackBerry Torch
My Carrier: AT&T

Re: user starts up the application by clicking a file

As one who's been around BlackBerry a long time, I can't help but think back to the first iteration of the Java SDK for the handhelds. Previous to that, it was a C++ SDK. I can assure you that the first iteration of the Java SDK was extremely weak compared to the latest C++ SDK. As a seasoned developer using the C++ SDK, the obvious shortcomings of the Java SDK were a huge turn-off.  In fact, RIM lost me as a developer for some 4 or 5 years. 

 

I expect the Playbook SDKs will also be weak compared to the current state of the Java SDK for the first 2 or 3 revisions.  It is understandably necessary to take these baby steps, so consider this to be a general warning: just because you could do it in the Java SDK, doesn't mean you will be able to do it in ANY playbook SDK, even the Java SDK for Playbook (when it is released).

 

Take my $.02 for what its worth. Smiley Happy

Bill

Bill
-------------------------------------------
Check out my book on BlackBerry Development for Java.
And my other really really old book
My Apps: FlashKids
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: user starts up the application by clicking a file

@bill: thats an excellent tip and i agree 100%! Smiley Happy

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman