On Sat, May 25, 2024 at 11:15 PM tor <
tommy.r...@gmail.com> wrote:
> Ok, unfortunately it is not clear to me why creating a java class of my own and interfacing it in python is different than interfacing google code direct.
Because:
1. Android provides generic Java API as the native native programming
language that runs on Dalvik machine that then uses Linux kernel API
to talk to hardware. Developer would have to talk to either Linux
kernel drivers directly (which may not be even possible in Android by
a security design but also Linux kernel API changes with every minor
release so you would have to customize your application for every
possible Linux kernel version out there), or by a generic set of
functions and parameters (API) dedicated to Java that is well defined
for a given API number (new Android API may change sensor handling
function names and parameters because of new features for example).
Because most people write native applications in Java on Android thus
the (versioned) Android API dedicated for Java programming language.
2. Kivy uses Python that is compiled into a binary form with NDK that
is then launched by a generic Adnroid application wrapper to launch
Python then main.py all that follows is the Python runtime. If you
want to use "outside" Java calls from "inside" Python you need to
create a "bridge" with PyJnius. Think of this as using "os" or "sys"
module in Python that allows working with the OS interface (i.e. env
variables, launching applications, etc).
> Guess it shows that I'm out of my depth here...
> The idea was to get a list of available sensors on the device, a no-go without java code then.
Most popular sensors can be accessed with Plyer because someone before
created a set of functions (API) that makes calling Java Sensor API
functions from Python code. If you need a sensor that is not yet
supported probably you will have to extend the Plyer and share back
the result. Maybe someone from the Plyer users/developers could help
you with that.. maybe even implement the feature if it benefits the
whole community. Maybe the sensor list is already available in Plyer
(I have no experience yet sorry). Please try creating an Issue at
Plyer GitHub repo to find out :-)