How to find Base Station Identifying Code (BSIC) - android

Is it possible to find Base Station Identifying Code in android. To clarify, Let 'A' calls to 'B'. Before 'B' receive the phone call, his installed app will find
'A's BSIC and match it with a given database of BSIC( this BSIC database may be located on phone locally or
in a web or from phone network provider's database ) then will find 'A' location( Say +88017... is calling from "Dinajpur of Bangladesh" ).Is it possible ? if so how ? please help me...

Rereading the question, you want the other person's tower, not your own. No, i don't think that info is available to you. At most, you can guess by the country and region codes.
Not relevant anymore:
I believe you can achieve what you want getting the cell id in use or all the neighboring cells
TelephonyManager mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation loc = (GsmCellLocation) mTelephonyManager.getCellLocation();
Log.d ("CID", Integet.toString(loc.getCid()));
Log.d ("LAC", Integet.toString(loc.getLac()));
// or
List<NeighboringCellInfo> list = mTelephonyManager.getNeighboringCellInfo ();
for (NeighboringCellInfo cell : list) {
Log.d ("CID", Integet.toString(cell.getCid()));
Log.d ("LAC", Integet.toString(cell.getLac()));
}
You can refer then to cell location through several open databases (e.g., http://www.location-api.com/ or http://opencellid.org/ )
If this is not enought, I suggest you to check this thread: http://groups.google.com/group/android-platform/browse_thread/thread/b55c8d3275ed7042/78d9c30c49e94a3a , specially this link: http://www.google.com/url?sa=D&q=http://www.3gpp.org/ftp/Specs/archive/27_series/27.007/27007-860.zip

Related

SubscriptionInfo.getMnc() drops leading zeros, cannot link MCC+MNC to SIM operator

I'm updating some code to use the Multi SIM support that was added to Android in 5.1. We examine the SIM operator (or the MCC+MNC combo) a lot in our app, so the code I'm writing involves migrating from reliance on TelephonyManager.getSimOperator() to getting SubscriptionInfos from the SubscriptionManager, each of which gives access to the MCC and MNC for a SIM.
//old way – can only access one SIM
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String simOperator = telephonyManager.getSimOperator();
//new way - gives access to all SIMs
SubscriptionManager subscriptionManager = (SubscriptionManager) context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
List<SubscriptionInfo> subInfoList = subscriptionManager.getActiveSubscriptionInfoList();
for(SubscriptionInfo info : subInfoList) {
int mcc = info.getMcc();
int mnc = info.getMnc();
//do some stuff...
}
I'm finding that because it's returning ints for MCC and MNC, you lose leading zeros that are in some of the MNCs. To see some examples, check out the table here. When you concat MCC+MNC you get the SIM operator, so it is important to keep the zeros that are often present. For example, NEXTEL in Mexico has a SIM operator value of "334090," but because the SubscriptionInfo returns ints for MCC and MNC, you get the values 334 and 90, respectively.
Given this issue, how can you reliably link a SubscriptionInfo's MCC+MNC pair to a particular SIM operator in a list of known SIM operators? Is this an oversight in the design of this API? Is there any other way to get the SIM operator for every SIM card that's in the multi-SIM phone?
MCC are always 3 digits, the rest is MNC, which as you correctly said, may have 2 or 3 digits.
If you parse the int to String, you can just get sub string of it and process the info as required.
Also it's a hidden method, but you can access it by reflection, to get the info you want in String format, this exists at least from Android 6 and Android 7
public String getSimOperator(int subId)
But I think SubscriptionManager way is safer since it's open API and for the moment you don't need to bother with Android versions handling it differently.
The best way to achieve this is to read IMSI from the SIM card. If you are reading the MNC+MNC directly and your user is on roaming or connected to another network then the values returned won't be reliable.
E.g. If your user is NEXTEL customer but is travelling or due to network connection issues connects to another network, lets say Telcel, then the value returned from MCC+MNC will be from Telcel.
In order to reliably match the operator of current SIM to predefined list, read IMSI value from SIM card using getSubscriptionId() from Telephony manager.
IMSI starts with MCC+MNC of the operator. You can easily check if MCC+MNC matches as follows
final String mccMncToCompare = "334090"; //You can also use Integer instead of string. You just have to perform type conversion
final TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
final String imsi= tm.getSubscriberId();
final boolean mccMncMatched = imsi.startsWith(mccMncToCompare);

Differentiate between international roaming and roaming with the country.

Do we have any flag or value on the phone which can help decide this ?
I think it's not possible, you can just differenciate whether you're using roaming or not, but at least officially I can't find any info about this.
getRoaming() from ServiceState class.
isRoaming() from NetworkInfo class.
Roaming detection in StackOverflow.
---- EDIT ----
As probably there's not a built-int method for this, you could simply define and keep an internal list of national telephony companies and see whether the SIM's operator match one of them, in which case you'll be having a national roaming, an international roaming if the current operator is not the same as the SIM's and it's not in your list, or no-roaming if the current operator matches the SIM's operator. The negative thing is that you'd need to keep track of all national operators and add it to the list if there's some new, but that's something that doesn't happen too often (or at least here).
So basically it would be something like this:
TelephonyManager telephMan = ((TelephonyManager) Context.getSystemService(Context.TELEPHONY_SERVICE));
// This will be the current registered operator
String currentOperatorName = telephMan.getNetworkOperatorName();
// This will return the SIM operator
String simOperatorName = telephonyManager.getSimOperatorName();
// Additionally you'll have to keep a list of national operators
ArrayList<String> myCountryOperators = new ArrayList<String();
myCountryOperators.add("...");
myCountryOperators.add("...");
...
if (currentOperatorName.equals(simOperatorName)) {
// No roaming
}
else if (myCountryOperators.contains(currentOperatorName)) {
// National roaming
}
else {
// International roaming
}
if it's a GSM phone, in my opinion is easier to compare the country code set in the SIM card with the country code of network carrier with TelephonyManager.getNetworkCountryIso() and TelephonyManager.getSimCountryIso()
If they match you're in same country, otherwise don't. And you don't need to keep a list of names...

How to point to country by it's name?

Assuming that I don't know my current location, how to move MapView to country by it's name?
What I'm trying to do is display user's country by country code in locale.
There isn't such a table in android with a link between country and geolocation that I'am aware of.
I believe the best approach is to get a list of all capital cities with latitude and longitude (you can get them here : list of capital cities) or a list of countries (you can get them from here : list of countries) and put it in a table in your application.
good luck.
Yes you can display User's country by Country Code.
As we have facility to get the CountryCode through Android Telephony Manager Api so.
1)You have to use Key Value pairs concept, Key as CountryCode and Value as Country.
like the following code:
TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
manager.getNetworkCountryIso();

How to find out carrier's name when using MVNO? (i want the one written in notification Bar)

I am just trying to get my carrier name.
The issue while trying to use:
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE));
String carrierName = manager.getNetworkOperatorName();
That is working great unless you are a MVNO (definition here: http://en.wikipedia.org/wiki/Mobile_virtual_network_operator)
For instance, in Belgium, we have the "Base" carrier that rent the network to some MVNO, like Toledo, Allo RTL, Mobile Vikings, etc...
In my notification bar, when using such virtual operators, I get their real names, but the code above just give me "Base" as String, and not the one I want.
I hope you understand what I mean.
I don't have a MVNO SIM card but the getSimOperatorName() method of the TelephonyManager might be the method you are looking for.
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
String carrierName = manager.geSimOperatorName();
I have a MVNE SIM card in Germany and the method returns an empty String, but the getNetworkOperatorName() method returns the right Operator for my SIM card.

knowing the network operator name

I want to get my network operator name in my app.
I am using fallowing methods in the TelephonyManager to get this:
TelephonyManager mTeleManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
mTeleManager.getSimOperatorName();
mTeleManager.getNetworkOperatorName();
mTeleManager.getSimOperator()
But I am getting empty values from the "getSimOperatorName()" and "getNetworkOperatorName()"..
I am getting numeric code from this "getSimOperator()" method, But I want know the alphabetic form of the operator name . Some thing like "T-Mobile" for Tmobile networks.
Pl. suggest me how to do this.
thanks.
Have you tried it on different phones/with different sim cards?
According to TelephonyManager.getLine1Number() returns Null
Hi All,
Here comes an explanation for this. It is not actually an issue, both information depends on some fields on the SIM card that are optional. So it might be empty if the SIM has no such optional fields or if the operator has set it empty.
Regards,
He is talking about
TelephonyManager.getLine1Number()
TelephonyManager.getSimOperatorName()

Categories

Resources