Welcome! Log In Create A New Profile

Advanced

Android: call state change...

Posted by Marijan Tomasic 
Android: call state change...
August 17, 2023 12:35PM
Greeting,

I'm doing a small test project on android, the app is playing radio streaming, and it should stop when the phone rings.

So I should call a certain function when the phone rings.
Since there is no direct way for my application to know when the phone rings, it should be programmed in native java.

I have no experience with java (I only know how to make some elementary functions), so it's too much for me, so I'm asking for help if someone has done it successfully.

This is approximately the java code I should embed in WINDEV Mobile:


// Listener to detect incoming calls. 

private class CallStateListener extends PhoneStateListener {
  @Override
  public void onCallStateChanged(int state, String incomingNumber) {
      switch (state) {
          case TelephonyManager.CALL_STATE_RINGING:

          // called when someone is ringing to this phone

           callWLProcedure("RadioStop");

          break;
      }
  }
}
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: