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.
Asked
Active
Viewed 1,160 times
1 Answers
3
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
}
}

vojta
- 5,591
- 2
- 24
- 64
-
Thanks, It appears that you have you proactive Handler. Which responds on an action from the SIM Toolkit applet. Can we rut this method when the SIM is powered up ? – Abhirup Ghosh Jan 24 '17 at 15:15
-
1@AbhirupGhosh Sorry, I don't understand your comment.... I use standard `ProactiveHandler`, which is usually available on SIM cards running Java Card. When would you like to initiate the proactive command? After some event? Or as a reaction to a direct SEEK API call? – vojta Jan 24 '17 at 20:20
-
Can I initiate it every time the sim is powered up without any interaction from the ME ? – Abhirup Ghosh Jan 25 '17 at 18:03
-
@AbhirupGhosh You could register your applet for some event (e.g. EVENT_FIRST_COMMAND_AFTER_ATR) and start the proactive command on this event. – vojta Jan 26 '17 at 14:10