There is no way to implement abstract class with pyjnius, and it wont
have a way ever i guess.
What you need to do is to write an implementation of the class in Java.
The goal is to register a method to call for each method that we could
extend. The steps would be:
1. Create yourself the interface, with the exact same definitions as the
abstract class (let's call it OnBluetoothGattCallback)
2. Implement the abstract class BluetoothGattCallback with a method for
setting a callback object of the type OnBluetoothGattCallback)
3. Implement each method and call the correct method of the callback
object instead.
So at the end, you should have something like that:
public class BluetoothGattImplem extends BluetoothGattCallback {
public interface OnBluetoothGattCallback {
// ... all the methods from BluetoothGattCallback here ...
// like:
void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic);
}
// private storage for the callback object
private OnBluetoothGattCallback callback = null;
// method to set the callback object
void setCallback(OnBluetoothGattCallback callback) {
this.callback = callback;
}
// implement all the methods, and redirect to the callback object
void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic) {
if (this.callback)
this.callback.onCharacteristicChanged(gatt, characteristic);
}
// ... do the same of all the next methods ...
4. Put the java into src/org/myapp, don't forget the "package
org.myapp;" in the java file too.
5. Then, you can... implement a
"org/myapp/BluetoothGattImplem$OnBluetoothGattCallback" instead, as you
wanted to do it.
6. Don't forget to use __javacontext__ = 'app', because you're going to
implement a java class that you defined, not a java class available on
the system api.
7. To use it, just do:
class PyBluetoothGattCallback(...):
__javainterfaces__ =
["org/myapp/BluetoothGattImplem$OnBluetoothGattCallback"]
__javacontext__ = 'app'
# ... implem here
BluetoothGattImplem = autoclass('org/myapp/BluetoothGattImplem')
pycallback = PyBluetoothGattCallback()
bg = BluetoothGattImplem()
bg.setCallback(pycallback)
8. You're done.
That's a general way that works for all the abstract class. It would be
nice for us to have a way for auto generating this java code / python
code anyway. If somebody hear me... :)
Good luck!
Mathieu
Le 21/01/2014 19:36, Arnaud Waels a �crit :
> 2014/1/21 Mathieu Virbel <
m...@kivy.org <mailto:
m...@kivy.org>>:
> <mailto:
am...@prodeo.es> a �crit :
> <mailto:
pyjnius-dev%2Bunsu...@googlegroups.com>.
> --
> You received this message because you are subscribed to the Google
> Groups "PyJNIus development ML" group.
> To unsubscribe from this group and stop receiving emails from it, send