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

Posts: 13
Registered: ‎02-26-2013
My Device: blackberry curve 8520
My Carrier: 9963563582

Implement custom url schema in blackberry

Hi i am implementing the url schema in android/ios with mime type as "myapp" and the url looks like follows




when i put the same mime type for BB,the browser is not redirecting to my application



here is the BB code.


* BrowserPlugin.java
* Copyright © 1998-2010 Research In Motion Ltd.
* Note: For the sake of simplicity, this sample application may not leverage
* resource bundles and resource strings. However, it is STRONGLY recommended
* that application developers make use of the localization features available
* within the BlackBerry development platform to ensure a seamless application
* experience across a variety of languages and geographies. For more information
* on localizing your application, please refer to the BlackBerry Java Development
* Environment Development Guide associated with this release.
package com.ca.secure.mail.util;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;

import net.rim.device.api.browser.field.BrowserContent;
import net.rim.device.api.browser.field.BrowserContentBaseImpl;
import net.rim.device.api.browser.field.RenderingException;
import net.rim.device.api.browser.field.RenderingOptions;
import net.rim.device.api.browser.plugin.BrowserContentProvider;
import net.rim.device.api.browser.plugin.BrowserContentProviderContext;
import net.rim.device.api.browser.plugin.BrowserPageContext;
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.component.LabelField;
import net.rim.device.api.ui.container.VerticalFieldManager;

* To test the plugin - create a file with xxxtest extension and associate that
* type with application/x-vnd.rim.xxxtest mime type on any web server.
public final class BrowserPlugin extends BrowserContentProvider implements BrowserPageContext

private static String[] ACCEPT = {"myapp"};
String username = null;
String[] retAr = new String[0];
Hashtable htUserDet = null;
private static final int BAOS_SIZE = 1024;
private static final int BUFFER_SIZE = 64;
public static String MODULE = "MyApplication";

* @see net.rim.device.api.browser.plugin.BrowserContentProvider#getAccept(net.rim.device.api.browser.field.RenderingOptions)
public String[] getAccept(RenderingOptions context)
Logger.out("Browserplugin", "In the getAccept ");
return getSupportedMimeTypes();

public BrowserContent getBrowserContent(BrowserContentProviderContext ctxt) throws RenderingException {

Logger.out("Browserplugin", "Inside the getBrowserContent ");
// Create browser content
BrowserContentBaseImpl cbase = new BrowserContentBaseImpl(ctxt
.getHttpConnection().getURL(), null, ctxt
.getRenderingApplication(), ctxt.getRenderingSession()
.getRenderingOptions(), ctxt.getFlags());

String msg = "";

VerticalFieldManager vfm = new VerticalFieldManager();
LabelField lb = new LabelField();

int modeHandle = CodeModuleManager.getModuleHandle(MODULE);
ApplicationDescriptor[] apDes = new ApplicationDescriptor[0];

if (modeHandle == 0) {
msg = MODULE + " not found";
} else {
apDes = CodeModuleManager.getApplicationDescriptors(modeHandle);
// Read parameters
byte[] bytes = null;
String str = null;

try {
InputStream is = ctxt.getInputStream();

if (is == null) {
is = ctxt.getHttpConnection().openInputStream();
bytes = readAndClose(is);
str = (new String(bytes)).trim();

// Launch application
ApplicationDescriptor apDes1 = new ApplicationDescriptor(apDes[0], new String[] {"browser", str});

catch (ApplicationManagerException e)
msg = MODULE + " launching error";

catch (IOException e) {
msg = "Error reading data";

// Set label
return cbase;

private static byte[] read(InputStream in) throws IOException {

if (in == null) {
return null;
ByteArrayOutputStream baos = new ByteArrayOutputStream(BAOS_SIZE);
byte[] buffer = new byte[BUFFER_SIZE];
int len;

while ((len = in.read(buffer)) != -1) {
baos.write(buffer, 0, len);
return baos.toByteArray();

private static byte[] readAndClose(InputStream in) throws IOException {
try {
return read(in);
} finally {
if (in != null) {
System.out.println("Closing input stream");

* @see net.rim.device.api.browser.plugin.BrowserContentProvider#getSupportedMimeTypes()
public String[] getSupportedMimeTypes()
Logger.out("Browserplugin", "In the getSupportedMimeTypes ");
return ACCEPT;

public boolean getPropertyWithBooleanValue(int id, boolean defaultValue) {
// TODO Auto-generated method stub
return false;

public int getPropertyWithIntValue(int id, int defaultValue) {
// TODO Auto-generated method stub
return 0;

public Object getPropertyWithObjectValue(int id, Object defaultValue) {
// TODO Auto-generated method stub
return null;

public String getPropertyWithStringValue(int id, String defaultValue) {
// TODO Auto-generated method stub
return null;




Please let me know how to implement the custom url schema in BB..i want to lauch the application once i visit the custom url




Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Implement custom url schema in blackberry

Sorry I have not looked at your problem in detail, just wanted to point you at HttpFilterRegistry if you hadn't already seen it.