Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Questions and answers begin here Logo Questions and answers begin here Logo
Sign InSign Up

Questions and answers begin here

Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Blog
  • Contact Us

How to get neighboring cell info in Android Q?

Home/ Questions/Q 344
Next
Answered
How to get neighboring cell info in Android Q?
kittawa_amors
kittawa_amors Teacher

I am an Android developer facing a problem in fetching the neighboring cell information in Android Q. I have tried the usual approach of using TelephonyManager, but it doesn’t seem to work in the latest Android version.
Here’s the code I have tried:

TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
CellInfoGsm cellInfo = (CellInfoGsm) telephonyManager.getAllCellInfo().get(0);
NeighboringCellInfo neighboringCell = telephonyManager.getNeighboringCellInfo().get(0);

When I run this code, I get an IndexOutOfBoundsException and the application crashes. So far, I have not found any other way to get this information in Android Q.
I have also tried using the ConnectivityManager class, but it doesn’t seem to provide the relevant information. Can anyone guide me on how to fetch the neighboring cell information in Android Q? Any help will be appreciated. Thanks in advance!

androidcell-towerinformationmobileneighboring-cell
  • 767
  • 0 Followers
  • 1
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    troztky Begginer
    2019-04-06T10:39:01+00:00Added an answer about 4 years ago

    Hello and welcome! I’m glad you’re seeking help with getting neighboring cell info in Android Q. As an expert on this subject, I’m happy to share my knowledge with you.
    In Android Q, there have been several changes to how you can access neighboring cell info compared to previous versions. One change, for instance, is that the getNeighboringCellInfo() method is deprecated and no longer works. Instead, you can use the new getAllCellInfo() method.
    To use the getAllCellInfo() method, you need to first check if your app has the necessary permissions to use it. You can do this by checking the ACCESS_FINE_LOCATION permission in your app’s manifest file. If this permission is not granted, you’ll need to request it at runtime.
    Once you’ve verified that the necessary permission is granted, you can request a TelephonyManager object and call the getAllCellInfo() method on it. This will return a list of CellInfo objects, which contain information about the current and neighboring cells.
    Keep in mind that getAllCellInfo() is only available on devices running Android Q or higher. If your app needs to support older versions of Android, you’ll need to use a combination of other methods, such as getCellLocation() and getNetworkType(), to approximate neighboring cell info.
    In summary, to get neighboring cell info in Android Q, you can use the getAllCellInfo() method after verifying that your app has the necessary permissions. While this may be a change from previous Android versions, it’s important to keep up with the latest updates to ensure that your app is both functional and secure.
    I hope this information helps you with your coding needs. If you have any further questions, please don’t hesitate to ask. Good luck!

    • 134
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. hoseinrahimi14460 Teacher
    2019-04-07T16:38:56+00:00Added an answer about 4 years ago

    Based on my expertise, another possible solution for getting neighboring cell info in Android Q is to use the TelephonyManager’s getAllCellInfo() method which returns information about all observed cell information from all radios on which the device can register. You can then loop through the CellInfo list and check for the neighboring cells using the CellInfo.isRegistered() and CellInfo.getRegistered() methods.
    Here’s an example code snippet:
    “`java
    TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    List cellInfoList = telephonyManager.getAllCellInfo();
    for (CellInfo cellInfo : cellInfoList) {
    if (!cellInfo.isRegistered() && cellInfo instanceof CellInfoGsm) {
    CellIdentityGsm identity = ((CellInfoGsm) cellInfo).getCellIdentity();
    // Do whatever you need with the neighboring cell info
    } else if (!cellInfo.isRegistered() && cellInfo instanceof CellInfoLte) {
    CellIdentityLte identity = ((CellInfoLte) cellInfo).getCellIdentity();
    // Do whatever you need with the neighboring cell info
    }
    }
    “`

    This solution will allow you to easily retrieve information about all neighboring cells and it’s more reliable because it works for all radio types on which the device can register.

    • 59
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.