Accessing device location using SIM card in Android
🕵️Accessing device location using SIM Card 🗺️📍

In this article, we’ll see how to access device location using the SIM card in Android without using GPS or location service

These days, almost many apps use the device location📍. There might be some use case in your app which is strongly dependent on the user’s location. For example, if you have developed a social app 💬 which shows posts of users and imagine you’ve feature which shows trending posts in user’s nearby area. For such use case, you’ll get user’s device location and after some processing, you’ll be able to manage this feature for your cool app.

But wait… 🤔

What if your app user’s enabled Mock location? 😮

If your cool app users have enabled mock locations then your feature will not work as expected. If the user is currently at Mumbai, India and he enabled mock location and showing his location at Beijing, China 😩 then that Indian user will see useless Chinese content in the app. Your cool app’s cool feature won’t work as expected 😢

Then is there any solution? 🤷‍♀️

Yes😃, for such use case you won’t need user’s perfect location. Just area/city level location is enough for such use case. You can get user’s cell tower location by extracting the SIM card📡 details from the user’s device.

The famous app TikTok app extracts SIM Card📶 details and fetches the user’s location for the perfect updates and avoiding spoofing of location.

How did we come up with this Idea? 💡

We at ScaleReal were developing a product which was heavily dependent on the user’s location and we thought “What if GPS location isn’t available due to conditions like device failure or bad weather or if user provides fake location” 🤔. We thoroughly studied these scenarios with all aspects 🧐 and came with the solution of using SIM card details to extract at least the cell tower location of the user. This solution helped us to pinpoint the user's location using cell tower triangulation and the results were even better when we wrote a custom algorithm on top of these two. In turn a better product! 😄

In this article, we’ll learn to access the device’s cell tower location by extracting SIM Card details from the device. So let’s start implementation.
['Shreyas Patil']
['Android Development', 'Networking', 'Location', 'Kotlin', 'Android']