Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: problem on TelephonyManager.listen


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Mar 30, 2018 9:56 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
saeed dehyadgari

Posts: 5
Registered: 10/21/06
problem on TelephonyManager.listen  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2018 10:06 PM
Hi
I want to listen on cell info change. I heve below code :
procedure TfrmMain.btnSitesClick(Sender: TObject);
var
  obj: JObject;
  TelephonyManager: JTelephonyManager;
  tListener : JPhoneStateListener;
begin
  obj := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.TELEPHONY_SERVICE);
  TelephonyManager := TJTelephonyManager.Wrap((obj as ILocalObject).GetObjectID);
  TelephonyManager.listen(tListener, TJPhoneStateListener.JavaClass.LISTEN_CELL_INFO or TJPhoneStateListener.JavaClass.LISTEN_CELL_LOCATION);
end;

How can i handle or use "tListener.onCellInfoChanged" procedure?
or, is my way correct for listening on cell info?
thanx
saeed dehyadgari

Posts: 5
Registered: 10/21/06
Re: problem on TelephonyManager.listen  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2018 12:11 AM   in response to: saeed dehyadgari in response to: saeed dehyadgari
saeed dehyadgari wrote:
Hi
I want to listen on cell info change. I heve below code :
procedure TfrmMain.btnSitesClick(Sender: TObject);
var
  obj: JObject;
  TelephonyManager: JTelephonyManager;
  tListener : JPhoneStateListener;
begin
  obj := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.TELEPHONY_SERVICE);
  TelephonyManager := TJTelephonyManager.Wrap((obj as ILocalObject).GetObjectID);
  TelephonyManager.listen(tListener, TJPhoneStateListener.JavaClass.LISTEN_CELL_INFO or TJPhoneStateListener.JavaClass.LISTEN_CELL_LOCATION);
end;

How can i handle or use "tListener.onCellInfoChanged" procedure?
or, is my way correct for listening on cell info?
thanx

I found that i must write a class that implements the JPhoneStateListener interface and overrides the onCellInfoChanged() method.
and write below codes:
type
  TMyphoneStateListener = class(TJPhoneStateListener, JPhoneStateListener)
    public
      procedure onCellInfoChanged(cellInfo: JList); override; cdecl;
      constructor create;
      Destructor Destroy; Override;
  end;

but, on compile give me many of errors such as :
[DCC Error] main.pas(51): E2137 Method 'onCellInfoChanged' not found in base class
[DCC Error] main.pas(49): E2291 Missing implementation of interface method JPhoneStateListener.onCallForwardingIndicatorChanged
and ...
would you please help me?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: problem on TelephonyManager.listen [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2018 9:56 AM   in response to: saeed dehyadgari in response to: saeed dehyadgari
saeed dehyadgari wrote:

*[DCC Error] main.pas(51): E2137 Method 'onCellInfoChanged' not found
in base class*

Don't declare 'override' on interface methods.

*[DCC Error] main.pas(49): E2291 Missing implementation of interface
method JPhoneStateListener.onCallForwardingIndicatorChanged*

You have to implement ALL methods of an interface. You can't pick and
choose which ones you want. The PhoneStateListener interface has 12
event methods.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02