views:

1306

answers:

3

Hi,

I'd like to know if it's possible to associate a protocol (for example: 'myapp') to a native application installed on a Blackberry (or Android) so that if a user types in 'myapp://xxx' in a web browser it calls the native application. In this case, how is it possible to achieve it ?

As far as I understood, it's possible to do it with iphone but I don't know if it's possible with blackberry or android.

Thank you in advance for any help to this issue

+6  A: 

For Android have a look at this question's answers:

http://stackoverflow.com/questions/525063/android-respond-to-url-in-intent

and also the following page especially in the section "Data Types" about android:scheme on this page:

http://developer.android.com/guide/topics/intents/intents-filters.html

For your app you would put something like the following in your AndroidManifest.xml:

<intent-filter><action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="myapp"></data>
</intent-filter>
AshtonBRSC
A: 

For blackberry devices running 4.0 or later (all "trackball" devices and up run at least 4.2) the following code is all you need:

// Get the default sessionBrowserSession
net.rim.blackberry.api.browser.browserSession = Browser.getDefaultSession();
// now launch the URL
browserSession.displayPage("http://www.BlackBerry.com");

Since this is a pretty reusable code segment I recommend placing it the following function:

public static void loadURL(String url)
{
    try{
        net.rim.blackberry.api.browser.BrowserSession bSession = net.rim.blackberry.api.browser.Browser.getDefaultSession();
        bSession.displayPage(url);
        bSession.showBrowser();
    }
    catch (Exception ex){
        System.out.println("Error loading url [" + url + "]: " + ex.getMessage());
    }
}
AtariPete
I'm sorry, but did you even read the question?
fiXedd
FiXedd, you're right I overlooked the question details. Either way it was properly modded down...
AtariPete
@AtariPete: If your answer is completely off, then you should either delete it or edit it to be relevant. That avoids more downvotes and losing more rep
Casebash
A: 

For BlackBerry - yes, to an extent, look at the net.rim.device.api.browser.plugin package (JDE 4.0.0 and later). It allows you to specify a callback interface for a given MIME type & other parameters.

Basically you subclass BrowserContentProvider to indicate the MIME type(s) you want to receive, and register with BrowserContentProviderRegistery.

I don't have a lot of experience with this - but it looks like you may be limited to providing custom rendering functionality - that may be ok for you. I'm not sure how limited your ability to do anything else would be - you'd have to try things out.

Anthony Rizk