<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kamyab Khosravi on Medium]]></title>
        <description><![CDATA[Stories by Kamyab Khosravi on Medium]]></description>
        <link>https://medium.com/@kamyab9k?source=rss-665cd5f1c6b9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MxabJZMhkO8JqWINbiAAeg.jpeg</url>
            <title>Stories by Kamyab Khosravi on Medium</title>
            <link>https://medium.com/@kamyab9k?source=rss-665cd5f1c6b9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 04:43:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kamyab9k/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Concurrency: From CPU Architecture to Threads and Kotlin Coroutines]]></title>
            <link>https://medium.com/@kamyab9k/concurrency-from-cpu-architecture-to-7threads-and-kotlin-coroutines-a1d2f0588eb6?source=rss-665cd5f1c6b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1d2f0588eb6</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[kotlin-coroutines]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[multithreading]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Kamyab Khosravi]]></dc:creator>
            <pubDate>Mon, 06 Oct 2025 09:18:26 GMT</pubDate>
            <atom:updated>2025-10-06T09:21:05.075Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LGji2aE6J4g_ZcKhSZ6Rcw.png" /></figure><h3><strong>Introduction</strong></h3><p>In this article, we will look into the journey of concurrency in the programming world, from the lowest-level hardware CPU mechanisms to multithreading in Java and its limitations, and finally, introduce Kotlin Coroutines and their suspension Powers.</p><h3>CPU architecture</h3><p>As the brain of every computing unit, this piece of hardware usually has 3 main sections regarding our topic, which act as an abstraction:</p><p><strong>Control unit</strong>: acts as the brain of the CPU because it controls and manages the execution of instructions</p><p><strong>Arithmetic Logic Unit: </strong>Performs Arithmetic and logical operations</p><p><strong>Memory Management Unit: </strong>Manages memory-related operations between RAM and CPU</p><p><strong>Registers: </strong>This is like the smallest short-term memory unit, and the only memory location that the ALU can operate on</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0KBsAUiZxAt9cr8eg1X_3A.png" /><figcaption>CPU doing instructions</figcaption></figure><p>Every operation that needs to be done by the CPU, like adding two numbers, is ultimately an Instruction<em>.</em></p><p><strong>Question<em>: How does the CPU manage these instructions?</em></strong><em> <br></em>It is handled within a unit called a process. These processes have an internal section called <strong>PCB</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*osTBKRBzRZEOOY9MeHKveg.png" /><figcaption>Process Control Block</figcaption></figure><p>PCB has different sections and registers to manage the state, ID, and memory of the process.</p><h3>Why is concurrency needed?</h3><p>Imagine two operations need to be done at the same time on <strong>different </strong>CPUs; they wouldn’t interrupt each other as they are using different memory units of different CPUs, so no big challenge here!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-0Y1qyYOQRhImy3zbc4vcg.png" /><figcaption>Two CPUs and two processes</figcaption></figure><p><em>But what if there are two different processes on the </em><strong><em>same </em></strong><em>CPU?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8kY8f6Ev856ODh4S3fs8A.png" /><figcaption>One CPU and two or more Processes</figcaption></figure><p>In this case, where there are two or more processes that need to be done simultaneously, the CPU has its own way of breaking down the processes into chunks and switching between them, which is more efficient than doing one task fully and going to the next.</p><p><strong>What is Context Switching in the CPU?<br></strong>Context switching refers to the mechanism by which a CPU switches from one task (or context) to another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oiw-NP-tEiOfuFZtFm1ScQ.png" /><figcaption>Switch between processes</figcaption></figure><h3>What is Fork?</h3><p>This method was used before multi-threading (still has some unique use cases). Let’s learn this concept with an example:</p><p><strong>Case</strong>: Imagine you want to sum the numbers between 1 and 100 with the CPU.</p><p><strong>First approach</strong>: This can be done within a single process, where all numbers are summed sequentially till the end.</p><p><strong>Second approach (Fork)</strong>: In this approach, a forked process is created from the original one with mostly the same PCB fields. The original process can sum the numbers from 1 to 50, and the forked process can do the same, but for 51 to 100. Finally, the outcome of the two processes will be summed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L8YCWEXf8D4o6clj2-DtIw.png" /><figcaption>Fork mechanism</figcaption></figure><h4>What was wrong with Fork?</h4><p>Copying the whole memory of the parent process and creating a forked one seemed heavy and had overhead. Processes occupy their own memory, so forking new ones would be resource-intensive.</p><p><em>So why not just keep the one process(with no fork), and just have different Threads within the same process, and share the identical rest?</em></p><h3>Multi-threading</h3><p>This is the Java Multi-Threading approach, where each Thread gets its own CPU Registers, Stack, and Program Counter (PC) while sharing the rest, including Heap memory space. This solves the memory separation problem in the previous Forking approach and is much more efficient.</p><p>This is how the <a href="https://developer.android.com/courses/extras/multithreading"><strong>official Android document</strong></a> describes Multi-Threading:</p><blockquote>To use processors more efficiently, the operating system can enable an application to create more than one thread of execution within a process. This is called <em>multi-threading</em>.</blockquote><blockquote>You can think of it as reading multiple books at the same time, switching between books after each chapter, eventually finishing all books, but you can’t read more than one book at the exact same time.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DpQ2tjzLUbbFwoNZ_pevrQ.png" /></figure><p>📝Now the registers thread will be passed to the CPU for Context Switching</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hu8P2lJbbK6eW2tbSZoL4A.png" /><figcaption>Context Switching with Register threads by CPU</figcaption></figure><p>On Android, the main thread is a single thread that handles all updates to the UI. This main thread, also called the <em>UI thread</em>, is also the thread that calls all click handlers and other UI and lifecycle callbacks. The UI thread is the default thread.<br>There are more pre-defined Threads as well.</p><h4>📚Mechanisms in multi-Threading</h4><p>Thread mechanisms and methods as <a href="https://developer.android.com/reference/android/os/Looper">Looper</a>(), <a href="https://developer.android.com/reference/android/os/MessageQueue">MessageQueue</a>, <a href="https://developer.android.com/reference/android/os/Handler">Handler</a>, and <a href="https://developer.android.com/reference/android/os/Looper#quit()">Quit</a>(), are built and managed to run tasks concurrently and more efficiently. Click the links to read more!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QUFVD5z9G80cOeoQlYM-cw.png" /></figure><h4>Limitations of this Multi-threading?</h4><p>As time goes on, optimization and efficiency of different mechanisms as threads, should also be upgraded. It came to the point where even creating a new thread and blocking it for an operation was not logical anymore.</p><p><strong>Example</strong>: Imagine a Request to the server in your application, which is done in a thread. Since I/O operations are time-consuming, the thread would be blocked until the response is received(which is bad!).</p><p>⚠️There are Java virtual Threads(Project Loom) in Java, which provide almost the same non-blocking behaviour as coroutines, but it is done by the JVM, and the developer has little control over structured concurrency.</p><h3>Kotlin coroutines</h3><p>To support efficient concurrency, Kotlin uses asynchronous programming built around coroutines, which let you write asynchronous code in a natural, sequential style using suspending functions.</p><p>According to the <a href="https://kotlinlang.org/docs/coroutines-overview.html"><strong>official document of Android</strong></a>:</p><blockquote>Coroutines are lightweight alternatives to threads. They can suspend <strong>without </strong>blocking system resources, making them better suited for concurrency.</blockquote><h4>What are suspending functions?</h4><p>It allows a running task to pause and resume later without affecting the underlying Thread or the structure of your code. <br>This behaviour is achieved through the keyword <strong>suspend.</strong></p><pre>suspend fun greet() {<br>    println(&quot;Hello world from a suspending function&quot;)<br>}</pre><p>You can also add <strong>delay() </strong>to simulate a suspended task, such as a request to the server or DB operations.</p><pre>suspend fun greet() {<br>    println(&quot;The greet() on the thread: ${Thread.currentThread().name}&quot;)<br>    delay(1000L)<br>}</pre><h3>To better understand the difference</h3><p>The code blocks below perfectly demonstrate the difference between Java multi-Threading and Kotlin Coroutines.</p><p><strong>Java multi-threading:</strong></p><pre>fun blockingNetworkRequest() {<br>    println(&quot;Request: Starting blocking call on thread: ${Thread.currentThread().name}&quot;)<br>    <br>    // ⚠️ This call blocks the entire thread.<br>    Thread.sleep(1500) <br>    <br>    println(&quot;Response: Blocking call finished on thread: ${Thread.currentThread().name}&quot;)<br>}</pre><p><strong>Suspending with Kotlin Coroutines:</strong></p><pre>suspend fun nonBlockingNetworkRequest() {<br>    println(&quot;Request: Starting non-blocking call on thread: ${Thread.currentThread().name}&quot;)<br>    <br>    // ✅ This call suspends the coroutine, but does NOT block the thread.<br>    delay(1500) <br>    <br>    println(&quot;Response: Non-blocking call finished on thread: ${Thread.currentThread().name}&quot;)<br>}</pre><p>📚You can read more about Kotlin Coroutine mechanisms and methods, including <a href="https://kotlinlang.org/docs/coroutines-overview.html#asynchronous-flow-and-shared-mutable-state">Asynchronous flow</a>, <a href="https://kotlinlang.org/docs/coroutines-overview.html#coroutine-context-and-behavior">Coroutine context</a>, and <a href="https://kotlinlang.org/docs/coroutines-overview.html#coroutine-context-and-behavior">dispatchers</a>.</p><p>References:<br><a href="https://kotlinlang.org/docs/coroutines-overview.html">https://kotlinlang.org/docs/coroutines-overview.html</a><br><a href="https://developer.android.com/">https://developer.android.com/</a><br><a href="https://www.youtube.com/watch?v=7PBQlD6v1HE">https://www.youtube.com/watch?v=7PBQlD6v1HE</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1d2f0588eb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to integrate the Gemini API into your Android project]]></title>
            <link>https://medium.com/@kamyab9k/how-to-integrate-gemini-api-into-your-android-project-80fe8422a9d8?source=rss-665cd5f1c6b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/80fe8422a9d8</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[gemini]]></category>
            <dc:creator><![CDATA[Kamyab Khosravi]]></dc:creator>
            <pubDate>Sun, 27 Jul 2025 17:51:53 GMT</pubDate>
            <atom:updated>2025-07-27T18:56:02.545Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GlJwcAL1blBRAef8aZRh5w.png" /></figure><h4>Follow this article’s 4 steps to have:</h4><p>Your own free customized AI model (e.g., AI Fitness Coach, AI math teacher) that can be integrated seamlessly into any Android application. You can choose between different Gemini API models (e.g., Gemini 2.5 flash), processing text, voice, video, and image.</p><p><strong>Let’s begin🚀</strong></p><h4>1. Getting the API key</h4><p>Go to <a href="https://aistudio.google.com/app/apikey"><strong>Google AI Studio</strong></a> and after signing in, click <strong>“Create API key”</strong> to get your API key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JyjLDrfEDfN8puKjKMiLnA.png" /><figcaption>Create API key</figcaption></figure><p><strong>Note</strong>: You may want to choose your existing Firebase project. If you don’t have one, an API key will still be generated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iDT15ZdI0tQO0l56O3R8ZQ.png" /><figcaption>Choose existing Firebase projects</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JGQTJp5lop3VvhzIoP4hdw.png" /><figcaption>API key generated</figcaption></figure><p>Congratulations! 👏 <br>Your generated API key is now ready. Let’s dive into your project in Android Studio.</p><h4>2. Adding Dependencies</h4><ul><li>First, you need to add the dependency for the Google AI client SDK and okhttp for Android to your app/build.gradle.kts file.</li></ul><pre>dependencies {<br>  // ... other dependencies<br>  //add the dependency for the Google AI client SDK and okhttp<br>  implementation(&quot;com.google.ai.client.generativeai:generativeai:0.9.0&quot;)<br>  implementation(&quot;com.squareup.okhttp3:okhttp:4.12.0&quot;)<br>}</pre><p>If you use <strong>version catalog</strong>, use this instead:</p><pre>[versions]<br>googleAiGenerativeai = &quot;0.9.0&quot; #Use latest version<br>okhttp = &quot;4.12.0&quot; # Use the latest version</pre><pre>[libraries]<br>google-ai-generativeai = { module = &quot;com.google.ai.client.generativeai:generativeai&quot;, version.ref = &quot;googleAiGenerativeai&quot; }<br>okhttp-core = { group = &quot;com.squareup.okhttp3&quot;, name = &quot;okhttp&quot;, version.ref = &quot;okhttp&quot; }<br>okhttp-logging-interceptor = { group = &quot;com.squareup.okhttp3&quot;, name = &quot;logging-interceptor&quot;, version.ref = &quot;okhttp&quot; }</pre><pre>// in your app/build.gradle.kts<br><br><br>dependencies {<br>// ... other dependencies<br>implementation(libs.google.ai.generativeai)<br>implementation(libs.okhttp.core)<br>implementation(libs.okhttp.logging.interceptor) // Optional, recommended for debugging<br>}</pre><h4>3. Sending a request to the Gemini API model</h4><ul><li><strong>Setting up data models </strong>to differentiate between users&#39; messages and AI responses.</li></ul><pre>enum class MessageSender {<br>    USER, AI<br>}<br><br>data class GeminiMessage(<br>    val text: String,<br>    val sender: MessageSender,<br>)</pre><pre>sealed class Result&lt;out T : Any&gt; {<br>    data class Success&lt;out T : Any&gt;(val data: T) : Result&lt;T&gt;()<br>    data class Failure(val exception: Throwable) : Result&lt;Nothing&gt;()<br>}</pre><ul><li><strong>Set up the API Client and Constants</strong> to make the network call, passing the API key and model name. I used OkHttpClient, but Retrofit2 is also fine.</li></ul><pre>import okhttp3.MediaType.Companion.toMediaType<br>import okhttp3.OkHttpClient<br><br>class GeminiRepository(<br>    private val apiKey: String,<br>    private val modelName: String,<br>) {<br>    // OkHttpClient is used for making network requests.<br>    private val client = OkHttpClient()<br><br>    // The media type for the request body is always JSON.<br>    private val mediaType = &quot;application/json&quot;.toMediaType()<br><br>    // ... (rest of the class)<br>}<br></pre><ul><li><strong>Prepare the Request Body</strong> <strong>(the “Prompt”) </strong>format for Gemini, containing a Content, which is the chat history, and an optional system instruction for customizing the persona of the model.</li></ul><pre>import org.json.JSONArray<br>import org.json.JSONObject<br><br>// ... inside your GeminiRepository class<br><br>suspend fun generateContent(history: List&lt;GeminiMessage&gt;): Result&lt;String&gt; {<br>    // 1. Build the API URL with your model name and key.<br>    val url = &quot;https://generativelanguage.googleapis.com/v1beta/models/$modelName:generateContent?key=$apiKey&quot;<br><br>    // 2. Create the JSON array for the conversation history.<br>    val contentsArray = JSONArray()<br>    history.forEach { message -&gt;<br>        val role = when (message.sender) {<br>            MessageSender.USER -&gt; &quot;user&quot;<br>            MessageSender.AI -&gt; &quot;model&quot;<br>        }<br>        contentsArray.put(JSONObject().apply {<br>            put(&quot;role&quot;, role)<br>            put(&quot;parts&quot;, JSONArray().apply {<br>                put(JSONObject().apply {<br>                    put(&quot;text&quot;, message.text)<br>                })<br>            })<br>        })<br>    }<br><br>    // 3. Combine the conversation history and a system instruction into a single JSON object.<br>    val jsonBody = JSONObject().apply {<br>        put(&quot;system_instruction&quot;, JSONObject().apply {<br>            put(&quot;parts&quot;, JSONArray().apply {<br>                put(JSONObject().apply {<br>                    put(&quot;text&quot;, &quot;You are an AI fitness coach named FitCore only answer to Fitness and exercise questions ... (your instructions here)&quot;)<br>                })<br>            })<br>        })<br>        put(&quot;contents&quot;, contentsArray)<br>    }.toString()<br><br>    // 4. Create the OkHttp request with the JSON body.<br>    val requestBody = jsonBody.toRequestBody(mediaType)<br>    val request = Request.Builder()<br>        ./service/https://medium.com/url(url)<br>        .post(requestBody)<br>        .build()<br><br>    // ... (go to Step 3)<br>}</pre><p>The request to the Gemini API is a POST request with a JSON body. This JSON body is where the &quot;prompt&quot; is sent.</p><p>✍️<strong>Note</strong>: Refer to the <a href="https://ai.google.dev/api/generate-content#v1beta.GenerationConfig">GenerateContentConfig</a> reference for a complete list of configurable parameters(e.g., temperature, thinking) and their descriptions.</p><h4>4. Getting the response</h4><ul><li><strong>This is where the network call happens</strong>. We’ll execute the request and then parse the JSON response to extract the generated text.</li></ul><pre>import okhttp3.Request<br>import kotlinx.coroutines.Dispatchers<br>import kotlinx.coroutines.withContext<br>import org.json.JSONObject<br>import java.io.IOException<br><br>// ... inside your generateContent() function<br><br>// Use withContext(Dispatchers.IO) to perform the network call on a background thread.<br>val responseString = withContext(Dispatchers.IO) {<br>    client.newCall(request).execute().use { response -&gt;<br>        if (!response.isSuccessful) {<br>            // Handle non-successful HTTP responses.<br>            throw IOException(&quot;API returned error: ${response.code} - ${response.message}&quot;)<br>        }<br>        response.body?.string() ?: throw IOException(&quot;Empty response body.&quot;)<br>    }<br>}<br><br>// Now, parse the successful JSON response.<br>val jsonResponse = JSONObject(responseString)<br>val candidates = jsonResponse.optJSONArray(&quot;candidates&quot;)<br><br>if (candidates != null &amp;&amp; candidates.length() &gt; 0) {<br>    val firstCandidate = candidates.getJSONObject(0)<br>    val content = firstCandidate.optJSONObject(&quot;content&quot;)<br>    if (content != null) {<br>        val parts = content.optJSONArray(&quot;parts&quot;)<br>        if (parts != null &amp;&amp; parts.length() &gt; 0) {<br>            val firstPart = parts.optJSONObject(0)<br>            if (firstPart != null) {<br>                val text = firstPart.optString(&quot;text&quot;)<br>                // Success! Return the generated text.<br>                if (!text.isNullOrEmpty()) {<br>                    return Result.success(text)<br>                }<br>            }<br>        }<br>    }<br>}<br><br>// If we reach this point, something went wrong with the JSON structure.<br>return Result.failure(IOException(&quot;Failed to parse API response.&quot;))</pre><p><strong>Note: This approach is for a simple test for a sample only.</strong> For any real application, you should use a ViewModel and follow the local.properties method to protect your API key.</p><ul><li><strong>Finally</strong>, prepare your <strong>Main Activity</strong> and a simple Jetpack Compose function to display the AI response.</li></ul><pre>class MainActivity : ComponentActivity() {<br><br>    private val TAG = &quot;GeminiDemoAI&quot;<br><br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        enableEdgeToEdge()<br><br>        // TODO: **WARNING: Do not do this for production.<br>        // This is a significant security risk.<br>        // Secure the API key.<br>        val apiKey = &quot;YourAPIKEy&quot;<br>        val modelName = &quot;gemini-2.5-flash&quot;<br><br>        val geminiRepository = GeminiRepository(<br>            apiKey = apiKey,<br>            modelName = modelName<br>        )<br>        var aiResponse by mutableStateOf(&quot;Fetching AI response...&quot;)<br><br>        lifecycleScope.launch {<br>            Log.d(TAG, &quot;Starting API call...&quot;)<br>            val history = listOf(<br>                // This is the message that user sends to AI model<br>                GeminiMessage(&quot;Hello, what is a good beginner workout plan?&quot;, MessageSender.USER)<br>            )<br><br>            when (val result = geminiRepository.generateContent(history)) {<br>                is Result.Success -&gt; {<br>                    aiResponse = result.data<br>                    Log.d(TAG, &quot;API Success: ${result.data}&quot;)<br>                }<br><br>                is Result.Failure -&gt; {<br>                    aiResponse = &quot;Error: ${result.exception.message}&quot;<br>                    Log.e(TAG, &quot;API Error: ${result.exception.message}&quot;)<br>                }<br>            }<br>        }<br><br>        setContent {<br>            GeminiDemoAITheme {<br>                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -&gt;<br>                    Column(<br>                        modifier = Modifier<br>                            .fillMaxSize()<br>                            .verticalScroll(rememberScrollState())<br>                            .padding(innerPadding)<br>                    ) {<br>                        ResponseDisplay(<br>                            text = aiResponse,<br>                            modifier = Modifier.fillMaxWidth()<br>                        )<br>                    }<br>                }<br>            }<br>        }<br>    }<br><br>    // A simple Composable to display the text<br>    @Composable<br>    fun ResponseDisplay(text: String, modifier: Modifier = Modifier) {<br>        Box(<br>            modifier = modifier<br>                .fillMaxWidth()<br>                .padding(16.dp)<br>                .clip(RoundedCornerShape(8.dp))<br>                .background(MaterialTheme.colorScheme.secondaryContainer)<br><br>        ) {<br>            Text(<br>                text = text,<br>                style = MaterialTheme.typography.bodyLarge,<br>                modifier = Modifier.padding(16.dp)<br>            )<br>        }<br>    }<br>}</pre><p>All Done!🎉</p><p>By running the app, the AI model&#39;s responses will be stored in aiResponse = result.data and both displayed on the mobile screen and printed in logcat for test purposes. You can handle it as you wish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0HGXjZ5JDH0DMPIfZ7OqeQ.png" /><figcaption>Gemini Respone to my question</figcaption></figure><p>🎁Full code and sample implementation repository of this article are available on <a href="https://github.com/kamyab9k/GeminiDemoAI"><strong>my GitHub</strong></a>!</p><p><strong>Extra</strong>: The AI fitness coach feature on the mobile app, <strong>FitCore: Home Workouts &amp; AI Coach</strong>, which I have launched using Kotlin, Jetpack compose, and Gemini Artificial Intelligence, was implemented using these same steps, showcasing Google’s Gemini potential in Android.<br><a href="https://github.com/kamyab9k/FitCore-Documentation">GitHub Docs + release APK available here!</a></p><p>References:<br><a href="https://developer.android.com/codelabs/gemini-summarize#0">https://developer.android.com/codelabs/gemini-summarize#0</a><br><a href="https://aistudio.google.com/apikey">https://aistudio.google.com/</a><br><a href="https://ai.google.dev/">https://ai.google.dev/</a></p><p>I am Kamyab💻<br>Follow for more articles with real-world Android app implementations!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80fe8422a9d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>