Abhirup Ghosh
Abhirup Ghosh

Reputation: 99

How to launch the browser with specific URL from Java Card 2.2.2 SIM card applet?

I am trying to build an application where my app sends an APDU to a Java Card applet on my SIM card. When this apdu is recieved I want my Applet to launch the browser with a specific URL. I can do the same in Java Card 3.0 Connected edition. I have read that Java Card 2.2.2 has a option in the proactive handler for launching browser, but I cannot find it. I would really appreciate if someone could show me how to do it.

Upvotes: 2

Views: 1271

Answers (1)

vojta
vojta

Reputation: 5661

Yes, it is possible. However, a lot of phones (especially those running iOS) do not support this, so you should always check the output of the TERMINAL PROFILE command first.

import sim.toolkit.*;
...

private final static byte[] URL = {
  (byte)'h', (byte)'t', (byte)'t', (byte)'p', (byte)':', (byte)'/', (byte)'/', (byte)'w', (byte)'w', (byte)'w', (byte)'.', (byte)'g', (byte)'o', (byte)'o', (byte)'g', (byte)'l', (byte)'e', (byte)'.', (byte)'c', (byte)'o', (byte)'m'
};
private static final byte PROFILE_LAUNCH_BROWSER = (byte)70;

private static final void browse() throws ToolkitException {
    if (MEProfile.check(PROFILE_LAUNCH_BROWSER)) { //checking if the device supports this proactive command
        ProactiveHandler proactiveHandler = ProactiveHandler.getTheHandler();
        proactiveHandler.init(ToolkitConstants.PRO_CMD_LAUNCH_BROWSER, (byte)0x00, ToolkitConstants.DEV_ID_ME);
        proactiveHandler.appendTLV(ToolkitConstants.TAG_URL, URL, (short)0, (short)URL.length);
        proactiveHandler.send();
    } else {
        //feature not supported, throw an exception or do something like that
    }
}

Upvotes: 3

Related Questions