Have you ever noticed how certain strings are underlined in native BlackBerry® smartphone applications? For instance, if you select a phone number that’s underlined or highlighted when reading a message, it is assigned a context-sensitive menu item. Wouldn’t it be great if your application took advantage of this functionality to launch a custom application, open the BlackBerry® Browser to a specific URL, send a message, or perform a number of other actions that provide an integrated user experience?
Good news! As a developer, you have the opportunity to leverage string pattern matching in your BlackBerry applications – which in turn provides a great element of a Super App experience. Starting in handheld 4.3, we introduced a PatternRepository API which allows you to programmatically add custom context-sensitive menu items to standard BlackBerry smartphone applications, based on the matching of text in active text fields with string patterns.
BlackBerry API package for pattern recognition:
Note: Prior to 4.3, this net.rim.device.api.util.StringPattern API was introduced in BlackBerry® Device Software 4.0 and requires you to implement your own string matching algorithm.
Possible use cases for pattern matching would include:
- Providing phone number lookup by automatically recognizing phone numbers and looking them up in a reverse phone number lookup database.
- Providing additional integration between BlackBerry device applications and third party applications by enabling users to seamlessly transition between applications based on string patterns.
Since pattern matching provides a starting point for the application, your application should be configured as an auto-start system module so that all of the components can be registered upon startup, as described in the knowledge base article referenced below. If you review the ZipCodeLookupSample sample application – which can be downloaded from the knowledge base article – it underlines a United States zip code and allows the BlackBerry smartphone user to look up more information on this zip code.
Please share your experiences in using pattern matching by posting your comments! Also, stay tuned for part two of this blog post, as we look into integrating through URLs using CHAPI, BrowserContentProvider and HTTPFilter.