I need a way to determine which cellular network band my phone is currently on, and which tower it is connected to.
How would I go about doing this? I know there is a "Service Mode" you can enter with the command *#0011# --> however this does not work on my phone.
If there is a way to create an application where I can get this information, that would be ideal. I believe I would need to access the internal telephony classes of the android OS - which can be accessed via reflection.
Thanks
Take a look at these:
http://developer.android.com/reference/android/telephony/gsm/GsmCellLocation.html
http://developer.android.com/reference/android/telephony/TelephonyManager.html
You can get the CellID with appropriate methods within these classes. The CellID is a unique number for each cell (or each sector) so that identifies the tower. But relating that number with a specific tower (that is, its location) is harder, as that usually is not public information.
I'm not sure if you can get the frequency band, but if the "cell info" methods mentioned in the above links include channel numbers (ARFCN), you can deduce the band from those numbers.
Related
I am a beginner in android developing and I am working on a project to create an app to locate cell phones without using GPS.Can anybody help me with how to get the RSSI for GSM and the distance if possible.Any code available for this purpose would be appreciated really.
I would also like to know, what other information can we get from the SIM card.
For SIM information including RSSI, you need to look at the Android Telephony and related APIs.
You can't get the distance from the base station though. You can get the Cell Id, which gives you a rough location if matched up to a database. Cell Id information is proprietary though, and publically available databases aren't always that accurate. Or you could use three Cell Ids + RSSIs to do a rough triangulation calculation yourself. The disadvantages with that are that many devices won't return cell info for the surrounding cells; you still need access to a reliable database of cell locations; ideally you should also include known WiFi hotspots; it's a lot of work to implement something that Android has already done.
Android handles location via its own location and location services APIs. LocationManager lets you choose the desired technology, e.g.NETWORK_PROVIDER or GPS_PROVIDER. So you could just choose not to use GPS, and let Android give you the best available result from the network.
Is it possible to get location of the caller when get a call? If so provide some links to achieve it. Thanks in advance..
Edit: OR else how to get at-least approximate location or lastly State name of the incoming number.
No. That data isn't carried over the phone call in the metadata, and there's no data connection in a phone call. Nor does it make sense for it to be sent- that['s a security nightmare. How would you like it if your worst enemy could find out where you are at any time just by calling you? Or a pedo could find a child's location by calling their phone? Or a rapist a woman's location by calling her? It's a bad idea. If you want to share your location with someone there's a variety of apps that do that, and just about all of them allow you to restrict that knowledge so you have some security. Use them instead.
Getting the exact location of a caller in mobile networks is theoretically impossible, due to the architecture of mobile networks.
Briefly speaking, Mobile networks divide land areas into "Hives", which determines a closed ploygon. The shape of the polygon is normally a hexagon which is adjacent to other hexagons. These hexagons are covered by BTS towers, which are responsible for responding to call requests, routing and call hand-over.
Some but not all providers enable their BTS to report their GPS coordinates and the database of all these coordinates is some kind of confidential data.
Again some but not all providers, make their databse of BTS towers available , which depends on the host country regulations and the provider company policies.
However there are databases on the web, which gather this coordinates of different providers but since the data is not gathered or distributed in an online and timely fashion, there may be complications, let alone the web service you need to use for querying which normally is not provided.
But since I assume you're in India, you may find this website useful.
EDIT
After googling , I found these websites that provide Cell-ID databses.
https://unwiredlabs.com/2
http://location-api.com/
http://www.opencellid.org/
https://wigle.net/
http://cellspotting.com/webpages/cellspotting.html
http://www.cellmapper.net/
http://www.opencelldb.net/
I want my application to work in specific region e.g US.
We can limit distribution of application from play market but i found there are some hacks to install those apps.
I have to somehow limit the use within application.
For that I can retrieve user's GPS location and use Google's Geocode API for first run. But what if user travels to some other region?
I will have to use Location change listener to cater this scenario, but this will drain battery.
If I go for device's timezone, User can change it.
Is there any other thing i can possibly do to restrict application to specific region?
You can also check for the network the user is registered on with TelephonyManager
You have 2 methods that can be helpful.
GetNetworkCountryIso
http://developer.android.com/reference/android/telephony/TelephonyManager.html#getNetworkCountryIso()
and
GetSimCountryIso
http://developer.android.com/reference/android/telephony/TelephonyManager.html#getSimCountryIso()
Explanation
getNetworkCountryIso() will give you the iso for the country which the user is currenty registered for.
ie: If you're from Albania (al) and went to travel to USA (us) this will return "us"
getSimCountryIso() will give you the iso for the country where the SIM provider's country code.. ie: If you're from Albania (al) and went to travel to USA (us) this will return "al"
UPDATE
You can integrate (if server side available) http://www.whois.net/ip-address-lookup/ to look for the device IP address. You can get the IP like this.
How to get IP address of the device from code?
With a combination of all this functions (Wifi, network provider, IP, GPS, Google Play regions) you can reduce a lot the use limitations of your app. In the other hand if the user it´s advance enough to fake the IP using a proxy, doesn't turn on the Wifi / GPS and doesn't have SIM card, there´s not much more to do.
Hope it helps :)
As a continuation to my comment, you could go by those lines of filtering users by country code.
The problem - only some carriers store the phone number on the actual SIM card. If so, you will be able to obtain it using
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();
To avoid the instances of those carriers who don't store the actual number on the SIM - there is no way to retrieve the number seeing it is not stored on the phone.
So, what I would do, is simply on the first run of application, request the user to input his full phone number (including country code) - and store that in SharedPrefs. Then, you will know if to run the app or not.
Good luck, hope this has helped!
Could I get MCC & MNC of the other party, either on an incoming or an outgoing call?
I am aware that you can get your own information from the SIM card but I am interested for the information of my contacts.
I guess I must be able to retrieve such information during a phone call.
So two main questions:
Is it allowed from the protocol?
Are there any classes inside Android API that provide such information? (looked up inside TelephonyManager but did not find any)
Like payeli has answered: No, you cannot.
Firstly, because there is no API for accessing the other party's cellular information. Secondly, because Android doesn't actually know. You can delve into the source code of the TelephonyManager, and you'll see that it only contains information about the local telephony provider.
Furthermore, the internal Android class Connection also shows no hint of any such information. (Regardless of the information it contains, it isn't accessible from the API, not even via reflection.)
That being said, there are currently services that provide some insight into phone numbers. Here in the Netherlands, KPN provides an API for looking up caller information, including the current coverage state of the phone, whether it's roaming or not, and other details. I'm not sure if the API is public yet or not, but perhaps there's a similar service available in your region.
No, you can only retrieve the MCC and MNC of your phone, not for third party numbers to which you make or recieve calls.
Reason: Calls target a phone number, not the MCC/MNC of the sending/receiving devices. The MCC / MNC tuple is used to uniquely identify a mobile phone operator/carrier, so if user is using carrierX at present, he will have one value of MCC/MNC, and if user changes mobile carrier/operator but retains same phone number, the the value of MCC/MNC will change but phone-number will still be constant.
So the mapping between phone number of a contact and MCC/MNC of their carrier are not fixed. So:
Could I get MCC & MNC of the other party, either on an incoming or an outgoing call? NO
I "play" with google/glm/mmap in order to find the coordinates of a cell. I note that the returned values can changed (queries on several days).
Any explanation ?
It appears that the coordinates returned are a weighted average of locations where cell phones reported connecting to that base station. That is, they are not the coordinate of the base station antenna. This is actually better for geolocation purposes since you want to know where the cell phone is, not where the base station is. One of the parameters returned with the coordinates is a measure of the "spread" of the reports --- which gives one some idea of how accurate the geo-location is likely to be. It appears that as reports continue to come in to mmap, the data base is updated and so changes are possible over time, usually rather minor.
Note that, in the case of CDMA at least, the true location of the base station antenna can be obtained using getBaseStationLatitude() and getBaseStationLongitude() methods on cellLocation in e.g. onCellLocationChanged() callback. This is not supported by all carriers. U.S. Cellular does provide this information, Verizon Wireless sadly does not. Femtocells do provide the information using their built in GPS. Again, depending on your application, knowing the base station location may not be what is required.