Latest / CyberSecurity Summary / Building Android Apps in Python Using Kivy with Android Studio: With Pyjnius, Plyer, and Buildozer
Transcript
- 0:00Speaker 1: Okay, let's unpack this. In a world just drowning in information,
- 0:04Speaker 1: where does a busy, curious mind go, you know, to
- 0:07Speaker 1: get genuinely well informed fast. You want the gold, the
- 0:09Speaker 1: surprising facts, the practical insights, without getting bogged down in
- 0:13Speaker 1: every single detail. And well, that's exactly our mission today.
- 0:17Speaker 1: We're taking a deep dive into the fascinating world of
- 0:19Speaker 1: building Android applications using Python, specifically with a framework called
- 0:23Speaker 1: kiv Our. Core material for this deep dive comes from
- 0:25Speaker 1: a really insightful guide building Android apps in Python using
- 0:29Speaker 1: Kivy with androids Studio with Pigeonius Plier and Buildozer by
- 0:32Speaker 1: Ahmed Fazzy Mohammed Gad. So we're here to extract those
- 0:35Speaker 1: essential nuggets, those aha moments and the practical knowledge, the
- 0:38Speaker 1: stuff that will let you walk away with a solid
- 0:40Speaker 1: grasp of out Python can well conger mobile development.
- 0:43Speaker 2: Yeah. And what's truly fascinating here is how this approach
- 0:47Speaker 2: radically challenges the traditional landscape. I mean, for years, Java
- 0:51Speaker 2: and Cotlin have been the undisputed kings of Android development.
- 0:55Speaker 2: This deep dive explores a really compelling alternative. It's one
- 0:58Speaker 2: that allows the huge community of Python developers to leap
- 1:02Speaker 2: into the mobile space using skills they already possess. That's
- 1:05Speaker 2: a game changer for many.
- 1:06Speaker 1: Really, that's a great point. It really does challenge the
- 1:09Speaker 1: status quo, doesn't it. So for someone maybe steeped in
- 1:12Speaker 1: Java or colin, what's the single most compelling reason they
- 1:16Speaker 1: should even consider this alternative beyond just its Python? Let's
- 1:20Speaker 1: kick things off with the kiv Foundation. Why Python for Android?
- 1:24Speaker 1: What exactly is kivy?
- 1:26Speaker 2: Well, okay, at its heart, kivy is a cross platform
- 1:29Speaker 2: Python framework. It's designed for building applications with what they
- 1:32Speaker 2: call a natural user interface or NUI. Now, this isn't
- 1:35Speaker 2: just about making buttons look nice. It's about making interfaces
- 1:38Speaker 2: feel intuitive, responsive, almost you know, touch first. But the
- 1:41Speaker 2: real hook, as you said, is cross platform. Write your
- 1:44Speaker 2: kiv code once and it runs unchanged on Windows, Linux, Mac,
- 1:47Speaker 2: Android and iOS devices.
- 1:49Speaker 1: Wow.
- 1:49Speaker 2: For a developer, that means huge time savings and reaching
- 1:52Speaker 2: a much wider audience. And thinking about the author's background
- 1:56Speaker 2: in deep learning machine learning, it just shows python incredible versatility. Right,
- 2:01Speaker 2: It's no longer just stuck in data science or web
- 2:04Speaker 2: back ends. It's actually powering interactive mobile applications.
- 2:07Speaker 1: Now that truly sounds like a developer's dream right once
- 2:11Speaker 1: run everywhere. So KIV is powerful, but it's not a
- 2:14Speaker 1: magic bullet on its own, is it? What's the unsung
- 2:17Speaker 1: hero here? The thing that truly bridges the gap between
- 2:20Speaker 1: your Python code and a working Android app? Yeah, and thybeah.
- 2:24Speaker 1: What's one surprising thing it handles that most developers dread?
- 2:27Speaker 2: Ah? That would be Bill Dozer. Absolutely think of Billdozer
- 2:30Speaker 2: as your personal mobile app construction crew. Its core function
- 2:34Speaker 2: is to take your KIPI Python project and meticulously package
- 2:36Speaker 2: it into an Android studio project. Then ultimately it compiles
- 2:40Speaker 2: it into that installable Android application package, the APK.
- 2:43Speaker 1: File oka the APK.
- 2:44Speaker 2: And one truly surprising, well helpful fact is how it
- 2:48Speaker 2: automates the whole Android SDK and NDK setup. Native development
- 2:53Speaker 2: often involves hours of you know, versioning, headaches and dependency. Hell,
- 2:58Speaker 2: Billdozer either fetches exactly what it needs or just lets
- 3:01Speaker 2: you point to your offline tools. It's a huge time saver, So.
- 3:04Speaker 1: It handles the messy bits automatically. Yes, how do you,
- 3:08Speaker 1: as the developer tell Billdozer what your app actually needs?
- 3:11Speaker 1: Is there like a central control panel for it?
- 3:14Speaker 2: Exactly Yeah. This entire packaging process is largely configured through
- 3:18Speaker 2: just one single file called billdozer dot.
- 3:20Speaker 1: Spec build dozer dot spec.
- 3:22Speaker 2: Okay, it's like the DNA of your app. Inside you
- 3:24Speaker 2: define crucial characteristics like your app's titles, say first app,
- 3:28Speaker 2: and unique identifiers like package dot name and package dot domain.
- 3:31Speaker 2: Those are absolutely vital for publishing later. You point it
- 3:34Speaker 2: to your main Python file using source dot dr. And
- 3:36Speaker 2: here's a really neat part the requirements proper. Right, You
- 3:40Speaker 2: simply list all the Python libraries your app needs, KIV, NumPy, whatever,
- 3:44Speaker 2: and Billdozer automatically downloads and links them, no manual fuss.
- 3:48Speaker 2: You also specify visual assets, define screen orientation, and critically
- 3:53Speaker 2: list the Android dot permissions your app requires, like Internet
- 3:56Speaker 2: or camera. Builldozer translates these directly to the androm manifest
- 4:01Speaker 2: dot xml file. It's incredibly efficient.
- 4:03Speaker 1: Okay, we've talked about the building blocks KIV and Billdozer,
- 4:07Speaker 1: but how do you truly bring your Python code to
- 4:09Speaker 1: life like seeing it run on an actual Android device.
- 4:13Speaker 1: Let's walk through that journey. Taking your very first Kidi
- 4:15Speaker 1: app from your desktop right into your hands. How does
- 4:17Speaker 1: that work?
- 4:18Speaker 2: Right? Well, the best practice, and what the book recommends
- 4:21Speaker 2: is to start simple. Build your kiv application first as
- 4:23Speaker 2: a desktop app.
- 4:24Speaker 1: Oh okay, desktop first.
- 4:26Speaker 2: Yeah. This lets you quickly iterate, test your logic, make
- 4:29Speaker 2: sure everything's working perfectly before you even think about mobile deployment.
- 4:33Speaker 2: The desktop phase is basically your debugging sandbox that makes sense.
- 4:37Speaker 1: And when you're mapping out that initial desktop app the
- 4:40Speaker 1: UI part, where do you focus? Is there a specific
- 4:44Speaker 1: kiv tool for separating the visual design from the actual code.
- 4:48Speaker 2: Absolutely. Kivy has its own specialized design language. It's called
- 4:52Speaker 2: kV language PD language. It's a declarative way to define
- 4:55Speaker 2: your user interface. It lets you elegantly separate the visual
- 4:58Speaker 2: design from your Python logic, which keeps your code clean
- 5:01Speaker 2: and your UI flexible. So, for example, instead of writing
- 5:04Speaker 2: lots of Python code to define every button's position and size,
- 5:07Speaker 2: you can do most of that in the kV file,
- 5:09Speaker 2: and within that you'll work with core UI concepts like
- 5:12Speaker 2: box layout that's a container that organizes things neatly in
- 5:15Speaker 2: rows or columns, and then common widgets like text input
- 5:18Speaker 2: for user input, label for text, and of course button
- 5:20Speaker 2: for interaction. kV handles the on press event for buttons
- 5:24Speaker 2: letting you easily connect taps to your Python functions.
- 5:26Speaker 1: Got it. So, once your desktop app is solid, looks good,
- 5:31Speaker 1: the transition to Android sounds like the moment of truth.
- 5:33Speaker 1: How smooth is that with Billdozer? Is it complicated?
- 5:36Speaker 2: It's surprisingly seamless. Honestly, Billdozer offers a single, really powerful command,
- 5:43Speaker 2: buildozer Android debug deploy run one command, one command. It
- 5:47Speaker 2: handles the entire pipeline. It builds your APK. Then if
- 5:51Speaker 2: you have a USB connected Android device with USB debugging enabled,
- 5:54Speaker 2: that's important. It deploys the app directly to it and
- 5:57Speaker 2: even launches it automatically. Anyone who's wrestled with manual APK
- 6:01Speaker 2: transfers or complex build scripts before, well, this feels like magic.
- 6:06Speaker 2: It really streamlines the whole process.
- 6:08Speaker 1: That's incredibly efficient. So once you've tested it on your device,
- 6:11Speaker 1: hammered out the bugs, and you're ready for the big stage. Right,
- 6:14Speaker 1: how does publishing work? Getting it onto Google Play? Right?
- 6:17Speaker 2: So publishing is the next logical step. For that, you'd
- 6:20Speaker 2: use a slightly different command, buildozer Android release release.
- 6:24Speaker 1: Okay.
- 6:24Speaker 2: This command creates a release version of your APK, which
- 6:27Speaker 2: is optimized for distribution. This release APK then needs to
- 6:31Speaker 2: be digitally signed. That's a crucial step for security and
- 6:34Speaker 2: identity verification. After signing, you can upload it to platforms
- 6:38Speaker 2: like Google Play. The book also emphasizes setting your target
- 6:41Speaker 2: API level properly, say API twenty six or higher now
- 6:45Speaker 2: to ensure compatibility and meet platform requirements.
- 6:48Speaker 1: That makes perfect sense. Okay, Now let's explore some more
- 6:51Speaker 1: advanced kivvy stuff beyond basic UI. What about interacting with
- 6:56Speaker 1: the device's hardware, like the camera.
- 6:59Speaker 2: Yeah, intergra the vice camera is a pretty common requirement
- 7:01Speaker 2: these days, right. Kiv provides a dedicated camera widget for
- 7:04Speaker 2: this hiple enough, it's your direct getway to pulling in
- 7:07Speaker 2: live video feeds. Now, there is a common hurdle. The
- 7:10Speaker 2: Android camera output often comes rotated in ninety degrees by default.
- 7:14Speaker 1: Thenoro oh right, I've seen that.
- 7:16Speaker 2: Yeah, So the book explains how Kiv's canvas instances and
- 7:20Speaker 2: context instructions are used to fix this. Think of the
- 7:23Speaker 2: canvas as like a painter's workspace. For that specific widget,
- 7:28Speaker 2: you can apply transformations directly to that canvas, things like
- 7:31Speaker 2: rotate with an angle negat ninety along with color and
- 7:35Speaker 2: rectangle instructions to make sure the camera feed displays correctly
- 7:38Speaker 2: for the user, and to.
- 7:39Speaker 1: Make sure those transformations only affect say, the camera view,
- 7:42Speaker 1: and not everything else on the screen.
- 7:44Speaker 2: Good point. Kiv offers push matrix and pop matrix instructions
- 7:48Speaker 2: for that. These act like a temporary scope for your canvas.
- 7:51Speaker 1: Instructions like parentheses for graphics.
- 7:53Speaker 2: Exactly. You push matrix to start applying transformations, do your
- 7:57Speaker 2: rotation or whatever, and then pop matrix this limit and
- 8:00Speaker 2: it's their effect just to the widget you intended preventing,
- 8:02Speaker 2: you know, weird unintended changes to other UI elements. It's
- 8:06Speaker 2: precise control.
- 8:07Speaker 1: Okay, precise control. Now, what about capturing images from that
- 8:10Speaker 1: camera widget, especially if you need it fast, like for
- 8:13Speaker 1: real time stuff? Saving to a file sounds slow.
- 8:15Speaker 2: Yeah, saving to a file every frame is definitely too
- 8:17Speaker 2: slow for real time. The book introduces Bellera read pixels
- 8:21Speaker 2: and get region.
- 8:22Speaker 1: Goal read pixels sounds low level.
- 8:25Speaker 2: It is a bit but think of these as super
- 8:27Speaker 2: fast direct memory grabs. Instead of writing an image to disk,
- 8:31Speaker 2: they scoop up the raw pixel data directly into memory
- 8:34Speaker 2: as biterer rays. This avoids all the file io overhead,
- 8:38Speaker 2: making them vastly more efficient for processing video streams or
- 8:41Speaker 2: doing things like continuous uploads.
- 8:42Speaker 1: Ah okay, continuous uploads. That leads perfectly into the next bit.
- 8:46Speaker 1: One really practical application discussed in the source material using
- 8:49Speaker 1: these fast methods is continuously uploading captured images to an
- 8:53Speaker 1: HTTP server. So you've got your crev app on the
- 8:56Speaker 1: phone acting as a client, and maybe a Python flask
- 8:58Speaker 1: gap running on a ser.
- 9:00Speaker 2: Somewhere exactly, and the server communication flow described is quite clever.
- 9:04Speaker 2: The Kiwi client first sends the image dimensions the width
- 9:07Speaker 2: and height to the flask server just once in a
- 9:09Speaker 2: preliminary post message. Why just once, Well, the image size
- 9:13Speaker 2: is usually fixed, right, so sending it repeatedly is just
- 9:16Speaker 2: wasted bandwidth. After that initial handshake, the client continuously uploads
- 9:20Speaker 2: the actual image data as byte arrays. On the server side,
- 9:24Speaker 2: the flask app receives these mit arrays, it processes them,
- 9:28Speaker 2: maybe using something like the Python imaging library pil dot
- 9:30Speaker 2: image dot from bytes, it might need to rotate them again,
- 9:34Speaker 2: you know, image dot rotate nash nine d for consistency,
- 9:37Speaker 2: and then it could display them maybe in an HTML
- 9:39Speaker 2: page that auto refreshes showing the incoming frames. It's a
- 9:42Speaker 2: pretty robust way to handle live data streams between device
- 9:45Speaker 2: and server.
- 9:46Speaker 1: Very cool. Okay, let's shift gears now to something really
- 9:49Speaker 1: fun but also potentially quite complex, building a game. The
- 9:54Speaker 1: book goes into detail on constructing a multi level adventure game.
- 9:57Speaker 1: For game development, the float layout widget apparently becomes article.
- 10:00Speaker 1: How does that change things compared to the box layout
- 10:02Speaker 1: we mentioned earlier?
- 10:03Speaker 2: Right, float layout is definitely a game changer for games. Literally.
- 10:08Speaker 2: Unlike box layout, which kind of rigidly arranges widgets in lines,
- 10:13Speaker 2: float layout gives you precise dynamic control over positioning and sizing.
- 10:18Speaker 2: You place widgets using relative coordinates what kiv calls pautient
- 10:22Speaker 2: for position and size hint for size. This lets elements
- 10:25Speaker 2: overlap or be placed exactly where you need them on
- 10:28Speaker 2: the screen, which is obviously essential for games.
- 10:30Speaker 1: Makes sense. You need things flying around, not just sitting
- 10:33Speaker 1: in neat.
- 10:33Speaker 2: Rows exactly, controlling character movement, item placement, handling dynamic scenes.
- 10:38Speaker 2: Float layout is built for that.
- 10:39Speaker 1: And what about the core mechanics of a game animation
- 10:42Speaker 1: Touch controls knowing when things bump into each other. How
- 10:46Speaker 1: does kiv make that accessible for Python developers? Is it hard?
- 10:50Speaker 2: Kivy actually makes these surprisingly intuitive For animation, you can
- 10:53Speaker 2: animate pretty much any widget property think potent for movement,
- 10:56Speaker 2: or even the source property of an image to change
- 10:59Speaker 2: character spraites over time. You can set durations, transitions, even
- 11:02Speaker 2: loop them easily.
- 11:03Speaker 1: Okay, animation sounds doable. What about touch screen?
- 11:06Speaker 2: Touch events are handled through simple methods like on touchdown
- 11:09Speaker 2: attached to your main layout or even specific widgets. This
- 11:13Speaker 2: gives you the coordinates of the tap, letting you translate
- 11:15Speaker 2: that directly into character movement or interaction.
- 11:17Speaker 1: And collisions, like knowing when the player hits a monster
- 11:21Speaker 1: or grabs a coin.
- 11:22Speaker 2: For collision detection, Kivy provides the collide widget function. It's
- 11:26Speaker 2: efficient and simply tells you if the bounding boxes of
- 11:29Speaker 2: two widgets are overlapping, perfect for detecting if your player
- 11:33Speaker 2: character runs into a monster or collects a coin. The
- 11:36Speaker 2: book shows examples changing character images based on movement direction,
- 11:40Speaker 2: having monsters move randomly collecting uniformly distributed coins. It demonstrates
- 11:46Speaker 2: how relatively straightforward these core mechanics are to implement in Kivy.
- 11:50Speaker 1: That sounds like a really solid foundation for building almost
- 11:52Speaker 1: any two D game. Now, how does kiv help structure
- 11:56Speaker 1: a larger game, maybe one with multiple levels of menuscreen
- 11:59Speaker 1: that sort of thing. Is it like Android activities?
- 12:01Speaker 2: That's a perfect analogy. Kivy uses screen and screen manager
- 12:04Speaker 2: classes for exactly this purpose.
- 12:06Speaker 1: Green and screen manager okay.
- 12:08Speaker 2: The screen manager acts like a controller, handling transitions between
- 12:11Speaker 2: different screen instances. Each screen could represent a distinct part
- 12:15Speaker 2: of your application, their main menu, level one, level two,
- 12:18Speaker 2: a game over screen, and so on. Keeps everything organized
- 12:21Speaker 2: and modular.
- 12:22Speaker 1: Right prevents one massive code file exactly.
- 12:25Speaker 2: The book also talks about screen life cycle events, things
- 12:28Speaker 2: like on pre enter, one enter, on pre leave. These
- 12:32Speaker 2: are crucial. They let you run code just before screen appears,
- 12:35Speaker 2: right when it appears, or just before it disappears. Think
- 12:38Speaker 2: about setting up a level when the player enters it,
- 12:40Speaker 2: or resetting things when they leave. Very useful for managing
- 12:44Speaker 2: game state per level. The game example also extensively uses
- 12:48Speaker 2: custom widgets, things like a monster widget, a character widget,
- 12:52Speaker 2: a coin widget. This encapsulates their specific look and behavior,
- 12:56Speaker 2: making it really easy to reuse them across multiple levels
- 12:59Speaker 2: and simplifying the overall development.
- 13:01Speaker 1: And of course, what's a game without sound? The deep
- 13:03Speaker 1: dive mentions adding background music, coin collection sounds, level completion fanfares,
- 13:08Speaker 1: even character death sounds. Those details really add polish, don't they?
- 13:12Speaker 2: Absolutely? Sound design is critical for immersion, Even simple sounds
- 13:17Speaker 2: make a big difference, and for keeping track of progress.
- 13:20Speaker 2: The book introduces using Python's built in Pickle.
- 13:23Speaker 1: Library Pickle for saving game data.
- 13:26Speaker 2: Yep, Pickle lets you easily serialized Python objects, so you
- 13:29Speaker 2: can save things like the player's score, the last completed level,
- 13:33Speaker 2: or maybe whether they've seen the final congratulations message. This
- 13:37Speaker 2: ensures players don't lose their progress when they close the app.
- 13:40Speaker 2: It also mentions creating a custom image button widget, specifically
- 13:44Speaker 2: for the level selection screen, combining visuals with button functionality.
- 13:48Speaker 1: Okay, this is all sounding incredibly capable, but let's pose
- 13:51Speaker 1: a critical question. Now we've seen Kiv's power for UI
- 13:55Speaker 1: games even server coms, But what if your Python KIV
- 13:58Speaker 1: app needs to access really specific Android native features stuff
- 14:02Speaker 1: it isn't easily done in pure Python, or maybe not
- 14:04Speaker 1: covered by a kivi's core widgets. How do you get
- 14:07Speaker 1: under the hood?
- 14:07Speaker 2: Right? That's where things get really interesting and where the
- 14:09Speaker 2: integration story deepens. The book first introduces a library.
- 14:12Speaker 1: Called Plier Plier p l yer that's right.
- 14:16Speaker 2: Plier is a Python library that aims to provide a
- 14:18Speaker 2: simple high level cross platform interface to common native device features,
- 14:24Speaker 2: think things like pushing notifications, reading battery status, controlling the flashlight,
- 14:29Speaker 2: accessing accelerometer data. It's convenient for these kinds of basic interactions. However,
- 14:34Speaker 2: it's important to note, as the book points out, that
- 14:36Speaker 2: at the time it was written, some key features in Plier,
- 14:39Speaker 2: like maybe more advanced camera control, specific audio functionalities, or
- 14:44Speaker 2: detailed Wi Fi info, were still marked as unimplemented or
- 14:48Speaker 2: maybe only worked on certain platforms.
- 14:50Speaker 1: Ah okay, so Plier is good for some common stuff,
- 14:53Speaker 1: but might have gaps if you need something really specific
- 14:55Speaker 1: or advanced.
- 14:56Speaker 2: Exactly, It's a good first step, often sufficient, but sometimes
- 14:59Speaker 2: you need more more direct control.
- 15:01Speaker 1: So if Plier isn't enough, if you truly need to
- 15:04Speaker 1: go deep into the Android system, what's the next level?
- 15:07Speaker 1: What's the tool that really lets Python talk directly to
- 15:10Speaker 1: Android's core? And does using that power come with like
- 15:13Speaker 1: extra complexity.
- 15:14Speaker 2: That's where Paganius comes into play, and yes, this is
- 15:17Speaker 2: incredibly powerful. Pygenis allows your Python can to directly reflect
- 15:21Speaker 2: and interact with Java classes running on the Android system.
- 15:24Speaker 1: Reflect What does that mean exactly?
- 15:26Speaker 2: Think of reflection here as Python gaining a deep understanding
- 15:30Speaker 2: of Java's internal structure. On the fly, it can look
- 15:33Speaker 2: up Java classes by name, find their methods, check their parameters,
- 15:37Speaker 2: create instances of Java objects, and call their methods all
- 15:40Speaker 2: from Python code. Whoa, It's like Python suddenly learns to
- 15:43Speaker 2: speak fluent Java. So, for example, you could directly call
- 15:47Speaker 2: standard Java methods like Java dot laying a dot system,
- 15:50Speaker 2: dot out, dot print in LN to print to the
- 15:52Speaker 2: Android log or more usefully, you could instantiate and control
- 15:57Speaker 2: the Android dot media dot media player Java class to
- 16:00Speaker 2: play audio files, giving you finer control than maybe a
- 16:03Speaker 2: simpler library offers. You can even display those little pop
- 16:06Speaker 2: up tost messages the short notifications at the bottom of
- 16:08Speaker 2: the screen by finding the current Android activity, which is
- 16:11Speaker 2: often Python activity, and calling its Java methods directly using Pagenius, So.
- 16:16Speaker 1: You're literally writing Python that calls Java code precisely.
- 16:19Speaker 2: The trade off, as you hinted, is complexity. It's powerful,
- 16:23Speaker 2: but you're now bridging two distinct programming environments. Debugging can
- 16:28Speaker 2: be trickier, as an error might originate in your Python logic,
- 16:31Speaker 2: in the pisenous bridge itself, or in the Java code
- 16:34Speaker 2: you're calling. You need some understanding of both sides.
- 16:37Speaker 1: That makes sense. Power comes with the responsibility, right, So
- 16:40Speaker 1: Pagnius gives Python direct Java access, and the ultimate integration
- 16:45Speaker 1: level discussed in the book seems to be actually working
- 16:47Speaker 1: inside the Android studio project that Buildozer creates. This sounds
- 16:51Speaker 1: like taking the training wheels off entirely. What are you
- 16:53Speaker 1: actually looking at when you open that project and what
- 16:55Speaker 1: can you do by diving into the Java side there?
- 16:58Speaker 2: Exactly? That's where you roll up your sleeves and get
- 17:00Speaker 2: full native control if you need it. When buildoser runs,
- 17:03Speaker 2: it doesn't just make an APK out of thin air.
- 17:06Speaker 2: It first generates a standard Android studio project structure. Inside
- 17:10Speaker 2: that project you find all the familiar Android files, the
- 17:13Speaker 2: Android manifests dot xml for permissions and app configuration, Python
- 17:17Speaker 2: activity dot java, which is usually the main entry point
- 17:20Speaker 2: activity that bootstraps the bike on environment, the build dot
- 17:23Speaker 2: Greedle files for managing dependencies, and the build process strings,
- 17:26Speaker 2: dot xml for text resources.
- 17:28Speaker 1: And so on. So it's a real Android project.
- 17:30Speaker 2: It's a completely standard Android studio project. And this raises
- 17:34Speaker 2: that important question what can you do by modifying this?
- 17:38Speaker 2: Well quite a lot. You could, for instance, add custom
- 17:41Speaker 2: native job of us like an Android text view or
- 17:43Speaker 2: button directly into the Android activity's layout file main dot xml. Usually,
- 17:48Speaker 2: maybe you want some native UI elements visible even during
- 17:51Speaker 2: the initial KIV loading screen. It helps you to understand
- 17:54Speaker 2: that KIV typically runs on top of SDL, the Simple
- 17:56Speaker 2: Direct Media Layer SDL is a cross platform library that
- 17:59Speaker 2: provides it's a low level drawing surface and handles input.
- 18:02Speaker 2: So the KIV interface is drawn onto an SDL surface
- 18:05Speaker 2: within the Android activity. Touch events are captured by the
- 18:08Speaker 2: Android system, passed to the SDL surfaces on touch method
- 18:11Speaker 2: in Java, and then forward it into the KIV event loop.
- 18:14Speaker 1: Okay, getting technical, but I see.
- 18:16Speaker 2: The layers right, and the book is a really compelling
- 18:18Speaker 2: example of leveraging this, integrating OpenCV, the big Computer Vision library.
- 18:23Speaker 2: You could add the OpenCV library as a standard dependency
- 18:26Speaker 2: in your build dug glidal file. Then you could write
- 18:29Speaker 2: Java code within your Python activity or another Java class
- 18:32Speaker 2: that performs OpenCV operations. Imagine having a button in your KIVUI.
- 18:37Speaker 2: When you press it, it uses pugnius to call a
- 18:40Speaker 2: custom Java method you wrote. That Java method then grabs
- 18:43Speaker 2: a camera frame, uses OpenCV to apply, say a canny
- 18:47Speaker 2: edge detection filter, and maybe displays the result in a
- 18:50Speaker 2: native image view, or even sends the process data back
- 18:53Speaker 2: to Python.
- 18:53Speaker 1: Wow. Okay, so you can have KIV handling the main
- 18:56Speaker 1: UI and logic, but delegate really heavy or platform specific
- 19:00Speaker 1: tasks like advanced image processing directly to Java open CV
- 19:03Speaker 1: running natively exactly.
- 19:05Speaker 2: It demonstrates truly deep, seamless interoperability. You get the best
- 19:09Speaker 2: of both worlds, Python's rapid development and kiv's cross platform UI,
- 19:13Speaker 2: combined with the full power of native Android APIs and
- 19:16Speaker 2: Java libraries when needed.
- 19:17Speaker 1: So let's try to bring this all together. We've covered
- 19:20Speaker 1: a lot today, haven't we. We've journeyed through how KIV,
- 19:22Speaker 1: along with tools like bill Doozer, really empowers Python developers
- 19:26Speaker 1: to build surprisingly sophisticated Android applications, not just a toy.
- 19:30Speaker 1: We saw how you go from simple UIs and basic
- 19:33Speaker 1: interactions all the way to building complex multi level games
- 19:36Speaker 1: with animations, collisions, sound qv offers incredible versatility there, and
- 19:42Speaker 1: then when pure Python our standard KiB widgets are quite enough,
- 19:45Speaker 1: we explored how plier offers a simpler bridge for common tasks,
- 19:48Speaker 1: and now Pivnius provides that really deep connection, letting Python
- 19:52Speaker 1: directly call Java code, which culminates in the ability to
- 19:55Speaker 1: modify the bill Dozer generated Android studio project itself, integrating
- 19:59Speaker 1: powerful native libraries like OpenCV directly. It's quite a spectrum
- 20:03Speaker 1: of possibilities.
- 20:04Speaker 2: Yeah, this deep dive really hammers home a core message.
- 20:08Speaker 2: Python's reach extends far, far beyond its traditional domains. Now
- 20:12Speaker 2: it's not just for data science or web back ends anymore.
- 20:14Speaker 2: It offers powerful, genuinely efficient solutions for cross platform mobile
- 20:19Speaker 2: app development. And the tools we discussed KIV, Billdozer, Pygenius
- 20:23Speaker 2: they make it truly accessible for the vast Python community
- 20:26Speaker 2: to step into the mobile world. They can turn complex
- 20:29Speaker 2: ideas into tangible apps without needing to completely abandon their
- 20:32Speaker 2: existing skills.
- 20:34Speaker 1: So what does this all mean for you listening right now?
- 20:36Speaker 1: Imagine the possibilities for innovation when you can combine Python's
- 20:40Speaker 1: rich ecosystem of libraries. It's ease of use with deep
- 20:43Speaker 1: control over native mobile features. What kind of unique cross
- 20:46Speaker 1: platform apps or maybe even games could you create next
- 20:49Speaker 1: that truly stand out from the crowd. Something to think about.