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
mja1986
Posts: 53
Registered: ‎08-27-2013
My Device: none
My Carrier: none
Accepted Solution

Registering custom URL scheme

[ Edited ]

Hi!

 

Is it possible to register a custom url scheme so that the system will launch my app when a link in the form "customscheme://idontcareaboutthefqdn/" is clicked?

I know one can register a fqdn by using HttpFilterRegistry, but I actually want to react to a scheme.

 

P.S.: As alwasy, I forgot to include the most crucial information...
BB API 6.0.0

 

Thx

Please use plain text.
Regular Contributor
mja1986
Posts: 53
Registered: ‎08-27-2013
My Device: none
My Carrier: none

Re: Registering custom URL scheme

I will also need this Information for BB-10 since the Intents that are available for this on Android have been stripped from the BlackBerry Android Runtime.

Please use plain text.
Regular Contributor
mja1986
Posts: 53
Registered: ‎08-27-2013
My Device: none
My Carrier: none

Re: Registering custom URL scheme

bump

Please use plain text.
Regular Contributor
mja1986
Posts: 53
Registered: ‎08-27-2013
My Device: none
My Carrier: none

Re: Registering custom URL scheme

[ Edited ]

I've now decided to go with PatternRepository, registering a regex, I've also defined a new "entry point" thats to be startet when the system boots and should pass String[]{"startup"} to the main method, this entry point is not shown at the home screen and is seemingly needed to register the regex to match all those strings against, the configuration of this new entry point was done using the application descriptor xml view in eclipse by checking some boxes...

The Problem is: There is no new menu item in the mail client despite a part of the message matches the regex.

Those are the run and toString methods of my ApplicationMenuItem:

	public Object run(Object arg0) {
		return new Object();
	}

	public String toString() {
		return "Blablabla";
	}

 And heres my main method:

	public static void main(String[] args) {
		if (args.length > 0 && args[0].equals("startup")) {
			ApplicationMenuItem[] menuItems = new ApplicationMenuItem[1];
			menuItems[0] = new MenuItem(0);
			PatternRepository.addPattern(ApplicationDescriptor.currentApplicationDescriptor(), "^scheme:\\/\\/\\S*",
					PatternRepository.PATTERN_TYPE_REGULAR_EXPRESSION, menuItems);
		} else {
			if (args.length > 0) {
				Intent.getInstance(args[0]);
			}

			MobileDecisionApp theApp = new MobileDecisionApp();
			theApp.enterEventDispatcher();
		}
	}

 And the mail I got reads something like this:

Sometext

scheme://blablabla...

moretext...

 P.S.: FYI: using

"scheme:\\/\\/\\S*"

instead of 

"^scheme:\\/\\/\\S*"

doesn't work either.

Please use plain text.
Regular Contributor
mja1986
Posts: 53
Registered: ‎08-27-2013
My Device: none
My Carrier: none

Re: Registering custom URL scheme

Ok, I now startet to write logs at system bootup and while browsing the log viewer i found some possibly interesting entries:
1.: Should I care about

CMM: appname(somenumber) no sig from 0x414252

 and if so, why?

2.: Same goes with 

net.rim.options - Exception in OptionsSearchEntity: null

 

3.: I am especially curious about this one:

System - Process MyApp(somenumber) queue overflow; oldest event dropped

 4.: There are the two messages I write to the logger myself before and after I have the regex registered at bootup, this actually happens between 1. and 2. and between the two messages nothing of interest seems to be going on, is it safe to assume that the regex got registered properly?

Of these 4 events 1. is the earliest while 3. is the latest.

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Registering custom URL scheme

Some quick answers:

1) Ignore, from memory just indicates a non RIM nodule has started

2) Interesting

3) Worrying

 

Now I have a theory here.  I think you are attempting to add the Pattern Registry etc before your application has actually been started. 

 

If you look at this statement:

PatternRepository.addPattern(ApplicationDescriptor.currentApplicationDescriptor(), "^scheme:\\/\\/\\S*",

 

This is run in your main() and main is NOT part of your application - it is used to start your application.  (actually it does become part of your Application but that is beyond scope at the moment). So what does ApplicationDescriptor.currentApplicationDescriptor() actually refer to?  A null Descriptor perhaps?

 

I would try to reworjk this so that the pattern registration becomes part of your Application, so that ApplicationDescriptor.currentApplicationDescriptor() actually references the applicaiton you want.  Something along these lines - see 'in here':

 

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

    public MyApp(String [] args) {
        this.invokeLater(new Runnable() {
            public void run() {
                // In here.....
            }
        });
    }

 Note, this is just a theory, I have not tested this. 

Please use plain text.
Regular Contributor
mja1986
Posts: 53
Registered: ‎08-27-2013
My Device: none
My Carrier: none

Re: Registering custom URL scheme

I restructured the App and Main in the way you suggested, which will make things easier overall I guess, and now the MenuItem gets added to the mail apps menu as soon as I touch the link (I didn't realize I had to do that as well). Plus, thanks to your post I think I might just have a slight idea about what I am actually doing here now, thanks! 

Please use plain text.