How to access Android APIs in a toga app #3743
-
Greetings everyone. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Yes, there is a way to access Android classes; however, BeeWare uses Chaquopy, rather than Pyjnius. The syntax for accessing Java classes is similar to that used by Pjnius, but not drop-in identical; see the documentation for details. It might be possible to use Plyer, but there will likely be some adaptation work required - either an adaptation layer to convert the usage of Pyjnius APIs into the comparable Chaquopy APIs; or to update Plyer to use Chaquopy APIs directly. Alternatively, you could write code directly against the TTS libraries using the Chaquopy APIs. The primary benefit of using a layer like Plyer is platform independence; but if you're only targeting Android, those benefits may not be a major concern. |
Beta Was this translation helpful? Give feedback.
-
@mhsmith |
Beta Was this translation helpful? Give feedback.
-
@mhsmith |
Beta Was this translation helpful? Give feedback.
-
So, one more thing. |
Beta Was this translation helpful? Give feedback.
Essentially yes -
import android
will work in a BeeWare app.If you want other examples of Chaquopy usage, the Android backend for Toga is entirely written using Chaquopy. The implementation of a widget like Button may be a helpful reference.
Rubicon Java is no longer used. Toga switched to using Chaquopy around 3 years ago.