1
votes

How I can get the netWorkOperator information on CodeNameOne? I need to get mcc and mnc from android. I found this code to get it on android.

TelephonyManager tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = tel.getNetworkOperator();

if (networkOperator != null) {
    int mcc = Integer.parseInt(networkOperator.substring(0, 3));
    int mnc = Integer.parseInt(networkOperator.substring(3));
}
1

1 Answers

0
votes

You can use native interfaces to invoke this code. You will need to keep the object passed to you during the init() method, this is the Android activity which you can use to invoke getSystemService() on. Check out the Zxing demo where native interface calling is demonstrated.

You will probably also need to add manifest permissions which you can do using the build argument android.xpermissions.