0

I'm new to Android and I use eclipse. I'm making an application with bluetooth on my Android phone and the version is 2.3. I use the example downloaded from the SDK manager and changes so it will work for me. In the example file "BluetoothServiceChat" they call the function public synchronized void stop().

Now Eclipse throws an error and it says "Cannot override the final method from Thread". What can I do to fix this?

I use the explanation about the code from here

Example code of the stop function:

/**
* Stop all threads
*/
public synchronized void stop() {
  if (D) Log.d(TAG, "stop");

  if (mConnectThread != null) {
      mConnectThread.cancel();
      mConnectThread = null;
  }

  if (mConnectedThread != null) {
      mConnectedThread.cancel();
      mConnectedThread = null;
  }

  if (mSecureAcceptThread != null) {
      mSecureAcceptThread.cancel();
      mSecureAcceptThread = null;
  }

  if (mInsecureAcceptThread != null) {
      mInsecureAcceptThread.cancel();
      mInsecureAcceptThread = null;
  }
  setState(STATE_NONE);

}

thanks in advance

Daan Mouha
  • 580
  • 1
  • 6
  • 20

3 Answers3

2

You can't. Final methods can't be overriden by design. The platform/framework developers didn't want application developers to override some methods for abstraction and security issues. This question is similar to yours:

Java `final` method: what does it promise?

Community
  • 1
  • 1
Flávio Faria
  • 6,575
  • 3
  • 39
  • 59
0

Maybe you should CALL it (the stop method) instead of overriding?

Stan
  • 6,511
  • 8
  • 55
  • 87
0

I found the answer to my question in another thread I wrote: android-the-return-type-is-incompatible-with-thread-getstate

Thank you all for your help

Community
  • 1
  • 1
Daan Mouha
  • 580
  • 1
  • 6
  • 20