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
Regular Contributor
Abhijitb
Posts: 66
Registered: ‎06-12-2010
My Device: 8300-Curve

Launching Blackberry Application via a Custom URL Scheme

Hi All,

 

Is it possible to launch an native app via html link. I came across an article for iOS which can do similar task.

 

My questions is:

 

1. Is it achievable using RIM API and does all BB OS versions support this?

2. If yes, does it support URL params and what is the maximum length?

link: http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html

 

---------------------------------------------

Regards,

Abhijit Brahmane.

html link
Regular Contributor
Abhijitb
Posts: 66
Registered: ‎06-12-2010
My Device: 8300-Curve

Re: Launching Blackberry Application via a Custom URL Scheme

Hi All,

 

I’m using the httpfilterregistry for the first time in my app. Any help on below would be highly appreciated

 Here's the details below,


What needs to be done:

To add HttpFilterRegistry functionality so the app can be invoked when clicked on a browser URL

 

What is implemented below

  1. A class(EntryPointForApplication)
  2. Defined a alternate entry point named “background1”
  3. Background class which takes care of HttpFilter registry
  4. Any changes needed on the HttpFilterRegistry classes (protocol)

 

Need your input on the following

  1. Is the flow correct
  2. I have included the HttpFilterRegistry classes from the demo samples. What has to be changed apart from the URL’s & package names so by clicking the link my app would start-up.

 

class EntryPointForApplication extends UiApplication

{

   public EntryPointForApplication()

   {

      GUIApplication scr = new GUIApplication();

      pushScreen(scr);

   }

 

   public static void main(String[] args)

   {

      if (args != null && args.length > 0 && args[0].equals("background1"))

      {

         BackgroundApplication backApp = new BackgroundApplication();

         backApp.enterEventDispatcher();

         backApp.setupBackgroundApplication();

      }

      else

      {

         EntryPointForApplication application = new EntryPointForApplication();

         application.enterEventDispatcher();

      }

   }

   class GUIApplication extends MainScreen

   {

      public GUIApplication()

      {

         add(new LabelField("Hello World"));

      }

   }

public class BackgroundApplication

{

   public BackgroundApplication()

   {

   }

   public void setupBackgroundApplication()

   {

      try

      {

         HttpFilterRegistry.registerFilter("na.blackberry.com", "com.rim.samples.device.httpfilterdemo.precanned", true);

         HttpFilterRegistry.registerFilter("www.rim.com", "com.rim.samples.device.httpfilterdemo.filter");

      }

      catch (ControlledAccessException cae)

      {

         // Re-throw exception with explicit message

         throw new ControlledAccessException(cae);

      }

   }

}

 

 P.S: adding above to my thread. I've asked moderator to remove the reply from scibsalv.'s post 

-Abhijit

Regular Contributor
Abhijitb
Posts: 66
Registered: ‎06-12-2010
My Device: 8300-Curve

Re: Launching Blackberry Application via a Custom URL Scheme

Anyone who as done on the httpfilterregistry part ...

 

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Launching Blackberry Application via a Custom URL Scheme

There is an bug in this code:

 

You have written:

 

         BackgroundApplication backApp = new BackgroundApplication();

         backApp.enterEventDispatcher();

         backApp.setupBackgroundApplication();

 

However

backApp.enterEventDispatcher();

does not return.  You have to do this setup before you enterEventDispatcher();

Regular Contributor
Abhijitb
Posts: 66
Registered: ‎06-12-2010
My Device: 8300-Curve

Re: Launching Blackberry Application via a Custom URL Scheme

Thnx Peter for the quick one,

I changed the bug that ws found but still the app dosen't get invoked... I'm I missing anything here?

Also it would be very helpful if you let us know on how to handle the Protocol class functionality i.e how does it work when a FQDN is selected from BB browser
Developer
rakesh86shankar
Posts: 1,005
Registered: ‎05-22-2009
My Device: Not Specified

Re: Launching Blackberry Application via a Custom URL Scheme

You could have forgot about the Changing of permission settings for browser(to allow)in the app PErmission settings.Plz Check that,i hope that could be the problem.

 

Regards

 

Rakesh Shankar.P

Regular Contributor
Abhijitb
Posts: 66
Registered: ‎06-12-2010
My Device: 8300-Curve

Re: Launching Blackberry Application via a Custom URL Scheme

Thanks Rakesh, I've changed the settings but still all in vain :smileysad:

Although is there is any customization needed in Protocol class?

Say,

I have a FQDN by www.TestMyPage.com

I create
HttpFilterRegistry.registerFilter(" www.TestMyPage.com", "com.rim.samples.device.httpfilterdemo.precanned", true);

And under Protocol class I change the html code for the PAGE_DATA byte[] .... Any other changes in here so the app would get invoked when i click on the above url using BB browser?
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Launching Blackberry Application via a Custom URL Scheme

Does the sample application work?

Regular Contributor
Abhijitb
Posts: 66
Registered: ‎06-12-2010
My Device: 8300-Curve

Re: Launching Blackberry Application via a Custom URL Scheme

Yes it does work.. on OS 7 simulator bundled with the eclipse v1.5 package.

when typed na.blackberry.com on the brower url field  the app showed a html page,

"This is a simple page that contains link to precanned italic and bold content"


pls correct me here : I'm requesting a UI to be invoked after this. Is this a correct one?

Contributor
bogdannistor
Posts: 14
Registered: ‎01-20-2011
My Device: BlackBerry Bold 9700

Re: Launching Blackberry Application via a Custom URL Scheme

Look in the RIM sample apps, more specifically HTTPFilterDemo.

You have to register a filter for the type of link you need the app to be triggered by (you'll need to put this code in the main method of you app):

HttpFilterRegistry.registerFilter("www.rim.com","com.rim.samples.device.httpfilterdemo.filter");

where "www.rim.com" is obviously the link that should open the app and the second parameter is the package that contains the "Protocol" class. The Protocol class has a callback method:

public Connection openFilter( String name, int mode, boolean timeouts ) throws IOException {

This method will be called each time the user clicks on a link that has the form specified by you. So, to open the app, in the "openFilter" method, do:

int modHandle = CodeModuleManager.getModuleHandle("YourAppModuleName");
        ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors(modHandle);
        try {
            ApplicationManager.getApplicationManager().runApplication(apDes[0]);
        } catch (ApplicationManagerException e) {
            e.printStackTrace();
        }