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
New Developer
johnc126
Posts: 3
Registered: ‎11-04-2008
My Device: Not Specified

Launching a web browser to my mobile site

 

I've been googling around and found several ways to do this, however none of them seem to work for everyone.  All I want is an application that will open the browser to my mobile website.  I've tried:

 

 

 

import net.rim.device.api.system.ApplicationDescriptor;
import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.system.ApplicationManagerException;
import net.rim.device.api.system.CodeModuleManager;
import net.rim.device.api.ui.UiApplication;

public class WebLaunch extends UiApplication {
public static void main(String[] args){
WebLaunch instance = new WebLaunch();
instance.enterEventDispatcher();
}

public WebLaunch() {
boolean retval = true;
int handle = CodeModuleManager.getModuleHandle("net_rim_bb_browser_daemon");
if (handle <=0 ){
System.exit(0);
}else{
ApplicationDescriptor[] browserDescriptors = CodeModuleManager.getApplicationDescriptors(handle);
if (browserDescriptors == null ){
System.exit(0);
}else{
if ( browserDescriptors.length <=0 ){
System.exit(0);
}else{
String[] args = {"url", "http://www.google.com"};
ApplicationDescriptor descriptor = new ApplicationDescriptor(browserDescriptors[0],"url invocation", args,null, -1, null, -1,ApplicationDescriptor.FLAG_SYSTEM);
try{
ApplicationManager.getApplicationManager().runApplication(descriptor);
}catch(ApplicationManagerException e){
System.exit(0);
}
System.exit(0);
}
}
}
}
}

 

and

 

import net.rim.device.api.ui.UiApplication;
import net.rim.blackberry.api.browser.Browser;
import net.rim.blackberry.api.browser.BrowserSession;

public class WebLaunch extends UiApplication
{

public static void main(String[] args)
{
WebLaunch theApp = new WebLaunch();
theApp.enterEventDispatcher();
}

public WebLaunch()
{
BrowserSession browserSession = Browser.getDefaultSession();
browserSession.displayPage
("http://www.google.com"); //or your intranet site
System.exit(0);
}

}

 

Neither way worked for everyone.  The way using the browsersession wouldnt work on the blackberry I have here (v4.2.2.148 platform 3.0.0.67, it would usually open the browser but stay at a forever loading screen.  Occasionally it would work).  Using the first way I mentioned worked on thsi phone and some others, but also threw a controlledAccessException on some other phones (v4.2.2.176, probably others too).  I tried setting all the permissiosn to Allow but no dice.  Everything works perfectly in simulators and is also signed. 

 

If anyone can end my headaches I'd appreciate it greatly.  :smileyhappy:

Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Launching a web browser to my mobile site

I finally gave up and used server side logic along with several version-specific builds. RIM's example still didn't get around the stuck on screen

problem unless you copy it exacytly ( I think the uiapplication was a natural thing to add, can't remember).

 

Anyway, I now have a custom browser that so far runs same version on 4.1-4.2xx and is compiled against

4.0.2.  Haven't fully tested it but it picks up most features of later versions at it uses the RIM browser

field and related classes.

 

Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Launching a web browser to my mobile site

You may even want to try your code without extending uiapplication if you don't need it.

I just ran into this problem again, but using a stub to launch my real app.

I was moving a bunch of code around, trying to package it ( literally as I generally develop without

packaging, LOL) and I had an unpacked stub that picks up a subclass of a parameter base class

( text processed to be specific for the customer ) and invokes a real app instance inside a package.

I had left the uiapp extend in and everything was wierd- I was getting server log entries from the app,

but nothing worked, my cell tower based GPS was failing, even though I got my target app to put up screens

and do other things. As soon as I removed that everything worked fine ( well, the app doesn't work but I have

sensical failure modes now).

 

Anyway, I remember that an uneeded extension of something really made for confusing results and the RIM browser

launching example didn't include this ( which again IIRC, I'm just reacting to an immediate problem which is

similar to if not identical one with the browser launching).

 

 

New Developer
johnc126
Posts: 3
Registered: ‎11-04-2008
My Device: Not Specified

Re: Launching a web browser to my mobile site

So I enabled device security on the simulator (didn't know that was an option, I don't actually use these things) and attached the debugger.  Something odd in the output appeared:

 

CMM: WebLaunch(3988) no sig from 0x545252
module 3988 cannot reference net.rim.device.api.system.ApplicationManager
Module 'WebLaunch' attempts to access a secure API.
Linker error: 'VerifyError' for WebLaunch

 

My application is, in fact, signed, and all the options were set to allow.  Why would it tell me I don't have access touse the secure api?

New Developer
johnc126
Posts: 3
Registered: ‎11-04-2008
My Device: Not Specified

Re: Launching a web browser to my mobile site

Bump.

 

So I take it then there is no way to get this to work?

Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Launching a web browser to my mobile site

RIM's accepted solution requires version detection. It is possible if you don't extend uiapplication

your most primitive approach will work for all but I haven't checked it. See my recent observations

about uiapplication problems while trying to package some of my own code. Removing this from my launche code

was one of the last things I did to get the RIM code to work.

 

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

Re: Launching a web browser to my mobile site


johnc126 wrote:

So I enabled device security on the simulator (didn't know that was an option, I don't actually use these things) and attached the debugger.  Something odd in the output appeared:

 

CMM: WebLaunch(3988) no sig from 0x545252
module 3988 cannot reference net.rim.device.api.system.ApplicationManager
Module 'WebLaunch' attempts to access a secure API.
Linker error: 'VerifyError' for WebLaunch

 

My application is, in fact, signed, and all the options were set to allow.  Why would it tell me I don't have access touse the secure api?


 

Please note that the signing process does not update the copy of your cod files in the BlackBerry Simulator.  If you have enabled device security, you'll need to manually copy your cod files to the simulator directory after they have been signed.
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