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

Native Development

Reply
Contributor
keatsp
Posts: 41
Registered: ‎10-16-2012
My Device: Bold 9000
Accepted Solution

Open browser from app.

How can I open the browser with a given url from within my app.  I usually do this within Qt by using 

 

Qt.openUrlExternally("www.google.com")

 

This doesn't seem to do anything from cascades.  Any help would be great.

Developer
Ebscer
Posts: 880
Registered: ‎08-31-2009
My Device: 9530, 9630, 9800, 8530, 9900, 9810, 9930, PlayBook, Dev Alpha

Re: Open browser from app.

I use the following code

 

attachedObjects:
[
    Invocation
    {
         id: invoke
         query: InvokeQuery
         {
		mimeType: "text/html"
		uri: "http://news.ebscer.com/"
		invokeActionId: "bb.action.OPEN"
         }
     }
]

Button
{
	text: "Open Website"               
	onClicked:
	{
		invoke.trigger("bb.action.OPEN")
	}
}

 This uses the invocation framework to launch the browser in a new window...


Read my thoughts on BlackBerry Development at news.ebscer.com
Contributor
keatsp
Posts: 41
Registered: ‎10-16-2012
My Device: Bold 9000

Re: Open browser from app.

Worked like a charm, you're a genius, thx.  Still a little curious why the single line of qt code I used to use in Qt creator doesn't work but I'll get over it.

Regular Contributor
alexchristou
Posts: 56
Registered: ‎03-02-2012
My Device: 9780 & Playbook 32GB & Dev Alpha

Re: Open browser from app.

any idea why


uri: "http://" + contentView.web

 

is not working?

 

contentView.web gives

 

 www.something_else_each_time.com 

Developer
smiley
Posts: 1,523
Registered: ‎07-14-2008
My Device: Z10

Re: Open browser from app.

this works for websites but if I want to invoke appworld what would the mimetype be?

 

application/???

 

or do I need to use an different method like the invoke client sample apps?

Developer
Ebscer
Posts: 880
Registered: ‎08-31-2009
My Device: 9530, 9630, 9800, 8530, 9900, 9810, 9930, PlayBook, Dev Alpha

Re: Open browser from app.

This same approach should work for AppWorld, but I don't believe that RIM has released the proper documentation on the invocation framework yet...


Read my thoughts on BlackBerry Development at news.ebscer.com
Contributor
djreyes
Posts: 35
Registered: ‎11-13-2010
My Device: Torch 9810

Re: Open browser from app.

What you put if you want to open a 'dynamic' link, one that would change all the time?

DJ Reyes
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Open browser from app.

[ Edited ]

djreyes, you can change the uri, but you need to wait until the onArmed handler fires on the Invocation before you can trigger it. There was another thread around here lately where we figured that out: http://supportforums.blackberry.com/t5/Cascades-Development/Dynamic-browser-invocation-in-qml/m-p/20...


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!
Contributor
djreyes
Posts: 35
Registered: ‎11-13-2010
My Device: Torch 9810

Re: Open browser from app.

Hi Peter, the url is something that is scanned and I want the result to open the browser. Is what you said needed for that?

DJ Reyes
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Open browser from app.

If you're using one of the invocation things that has an onArmed, I suspect you need to do it something like that. That's the only time I tried anything with invocation yet though, aside from launching BB World with a fixed uri, so I can't say for sure.

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!