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

Java Development

Reply
Developer
Doctor
Posts: 73
Registered: ‎07-15-2008
My Device: Not Specified
Accepted Solution

Open a file in a default application

Hello Everyone!

 

I am using JDE 4.2 to develope a BlackBerry application. I want to open a file in the default application supported by BlackBerry device.

 

Let me explain in depth. Whenever user selects a file to open, I want to open that file in the default application without telling the device in which application the file should be opened. In JDE 4.3 and later, this can be achieved using javax.microedition.content.Invocation and javax.microedition.content.Registry APIs. Here is the code snippet how it can be done in JDE 4.3 and later.

 

 

Invocation invocation; invocation = new Invocation("file:///store/samples/contacts/BlueDress.png"); Registry _registry=Registry.getRegistry("net.rim.device.api.content.BlackBerryContentHandler"); _registry.invoke(invocation);

 

 The above code will open the BlueDress.png file in the default application.

 

But this is not supported in JDE 4.2 and the earlier version.

 

Can anyone help me how can I achieve the same in JDE 4.2?

 

 

 

 

Thanks,

- Rohan 

 

Retired
ttahir
Posts: 36
Registered: ‎07-14-2008
My Device: Not Specified

Re: Open a file in a default application

As you said, we didn't support JSR-211 Content Handler API in JDE/Handheld versions prior to v4.3.0.

 

For mime-types that the BlackBerry Browser can support, you can invoke the Browser with the particular URL (either to the internet or to the local filesystem). Take a look at these KB articles:

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/How_To_-_Invoke_the_default_browser.htm... 

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/How_To_-_Invoke_a_non-default_browser_s...

 

Tariq

Developer
Doctor
Posts: 73
Registered: ‎07-15-2008
My Device: Not Specified

Re: Open a file in a default application

Hi Tariq,

 

Thanks a lot for a quick reply. So, that's for sure now that it can't be done in 4.2

 

I have gone throught the links you mentioned. I have one more question regarding this:

In one of the article which you have mentioned, this is how the URL is being invoked.

 

BrowserSession browserSession = Browser.getDefaultSession(); browserSession.displayPage("http://www.google.com");

 Now, can you please tell me what should I do if I want to invoke a local file instead of "www.google.com" here?

 

 

 

Thanks,

- Rohan 

 

 

Developer
kzettel
Posts: 120
Registered: ‎07-16-2008
My Device: 9000

Re: Open a file in a default application

Use the same code with the file protocol in your url.

 

ie: "file://store/home/user/pictures/1.png"

Kurt Zettel | Chief Architect | Metova
www.metova.com
Developer
Doctor
Posts: 73
Registered: ‎07-15-2008
My Device: Not Specified

Re: Open a file in a default application

Hi Kurt,

 

I did the exact thing, but it gives me a message as mentioned below.

 

"A problem occurred while trying to render the page" 

Developer
kzettel
Posts: 120
Registered: ‎07-16-2008
My Device: 9000

Re: Open a file in a default application

I have a few questions to help you try to troubleshoot this:

 

1. Which type of file are you trying to open?

2. How large is the File?

3. Can you put the same file on a web server and open it remotely by browsing to the address?

4. Do you have a network connection when you try this? (It is a know feature of some versions of the browser that it will not open a local file if it does not have signal)

5. Is there any more detail on the error in the browser? (such as a detail button or by viewing the device's event log)

Kurt Zettel | Chief Architect | Metova
www.metova.com
Developer
Doctor
Posts: 73
Registered: ‎07-15-2008
My Device: Not Specified

Re: Open a file in a default application

Here are my answers:

 

1. PNG

2. No idea

3. No, but i can open png files from the server using browser

4. Yes

5. No 

 

 

Thanks,

- Rohan 

BlackBerry Development Advisor
MSohm
Posts: 14,753
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Open a file in a default application

Can you provide an exmaple URL you are using?  Please note that the file connection requires 3 slashes.  Example:

 

file:///SDCard/directory/file.png

 

 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
kzettel
Posts: 120
Registered: ‎07-16-2008
My Device: 9000

Re: Open a file in a default application

If you cannot open this file from the server but you can open other png files it may indicate that you have a bad png file.  Can you give us a url to the same file that we might be able to test on some other devices?
Kurt Zettel | Chief Architect | Metova
www.metova.com
Developer
Doctor
Posts: 73
Registered: ‎07-15-2008
My Device: Not Specified

Re: Open a file in a default application

Hi Mark,

 

Yeah, you are right, file connection requires 3 slashes and I am exactly providing three slashes as you have mentioned here.

 

Here is my code snippet:

 

 

BrowserSession browserSession = Browser.getDefaultSession(); browserSession.displayPage("file:///store/samples/pictures/Amphibian.png");

 

 

Thanks,

- Rohan