Xamarin TelephonyManager requestCellInfoUpdate how run?

DustOfRust 141 Reputation points
2021-04-13T21:09:14.733+00:00

How to run this method?

public void requestCellInfoUpdate (Executor executor, 
                TelephonyManager.CellInfoCallback callback)

My code:

    TelephonyManager tm = (TelephonyManager)this.GetSystemService(TelephonyService);
    tm.RequestCellInfoUpdate(MainExecutor, new TelephonyManager.CellInfoCallback());

new TelephonyManager.CellInfoCallback()) - this is a problem with that, but I don't know. How to start it and what to enter? From what I can see it's an abstract class?

I can't find anything in the Xamarin documentation. And in the Adnroid documentation, I found that it is necessary to call it from API29 to refresh the information.

Apps targeting Android Q or higher will no longer trigger a refresh of the cached CellInfo by invoking this API. Instead, those apps will receive the latest cached results, which may not be current. Apps targeting Android Q or higher that wish to request updated CellInfo should call requestCellInfoUpdate(); however, in all cases, updates will be rate-limited and are not guaranteed. To determine the recency of CellInfo data, callers should check CellInfo#getTimeStamp().

https://developer.android.com/reference/android/telephony/TelephonyManager#requestCellInfoUpdate(java.util.concurrent.Executor,%20android.telephony.TelephonyManager.CellInfoCallback)

Developer technologies | .NET | Xamarin
{count} votes

Accepted answer
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,756 Reputation points
    2021-04-14T05:48:16.363+00:00

    Hello,

    Welcome to Microsoft Q&A!

    We can create a new class inherit from the abstract class TelephonyManager.CellInfoCallback , and override the method OnCellInfo inside the new class .

    Check the code below

       public class MyCallBack : TelephonyManager.CellInfoCallback  
           {  
               public override void OnCellInfo(IList<CellInfo> cellInfo)  
               {  
                   //here get cell info  
               }  
           }  
         
        TelephonyManager tm = (TelephonyManager)this.GetSystemService(TelephonyService);  
        tm.RequestCellInfoUpdate(MainExecutor, new MyCallBack());  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.