<?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 Mohammad AlHussain on Medium]]></title>
        <description><![CDATA[Stories by Mohammad AlHussain on Medium]]></description>
        <link>https://medium.com/@m.alhussein.96?source=rss-65d7e00a2039------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hCVGHQK8ZTpgmYIYd0WOtg.jpeg</url>
            <title>Stories by Mohammad AlHussain on Medium</title>
            <link>https://medium.com/@m.alhussein.96?source=rss-65d7e00a2039------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 15:39:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@m.alhussein.96/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[Integrating AI (OCR) into Logistics: A Practical Success Story from Android Engineering]]></title>
            <link>https://medium.com/@m.alhussein.96/integrating-ai-ocr-into-logistics-a-practical-success-story-from-android-engineering-4c922c9550ed?source=rss-65d7e00a2039------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c922c9550ed</guid>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ml-kit]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Mohammad AlHussain]]></dc:creator>
            <pubDate>Mon, 02 Feb 2026 08:17:14 GMT</pubDate>
            <atom:updated>2026-02-02T08:17:14.077Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the most rewarding moments in my career as an Android Engineer was successfully introducing <strong>AI-driven automation</strong> into the logistics and warehouse management industry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PJKkSRsYY5NBpJe5l8jSNg.png" /></figure><p>In retail, logistics, and warehouse operations, many workflows are still highly manual. In one of the systems used at my company, handling a single parcel required multiple repetitive steps:</p><ol><li>Scanning the QR code on the parcel</li><li>Manually entering the customer ID printed on the label</li><li>Assigning the parcel to the correct box based on the customer</li></ol><p>These steps had to be repeated <strong>for every single parcel</strong>, which made the process slow, error-prone, and heavily dependent on human input.</p><h3>Identifying the Problem</h3><p>After analyzing the workflow, it became clear that the issue wasn’t the system itself — but the <strong>manual data entry</strong>. Most of the required information already existed on the parcel label; it simply wasn’t being used efficiently.</p><p>That’s when the idea emerged:<br><strong>Why not let AI read and extract the data automatically?</strong></p><h3>The Solution: OCR + Barcode Scanning</h3><p>To reduce operational time and speed up parcel handling, I integrated <strong>Google ML Kit</strong> into the Android application, combining:</p><ul><li><strong>Barcode scanning</strong> to read QR codes</li><li><strong>Text recognition (OCR)</strong> to extract customer details directly from the parcel label</li></ul><h4>Barcode Scanning</h4><p>Using ML Kit’s barcode scanner, the app reads QR codes directly from the parcel:</p><pre>val options = GmsBarcodeScannerOptions.Builder()<br>   .setBarcodeFormats(<br>       Barcode.FORMAT_QR_CODE)<br>   .build()<br><br>val scanner = GmsBarcodeScanning.getClient(this, options)<br><br>scanner.startScan()<br>   .addOnSuccessListener { barcode -&gt;<br>       // Task completed successfully<br>   }<br>   .addOnCanceledListener {<br>       // Task canceled<br>   }<br>   .addOnFailureListener { e -&gt;<br>       // Task failed with an exception<br>   }</pre><h4>Text Recognition (OCR)</h4><p>Next, I implemented <strong>Text Recognition v2</strong> to extract key information from the parcel label, such as:</p><ul><li>Customer name</li><li>Customer ID</li><li>Suit / box identifier</li></ul><pre>implementation &#39;com.google.android.gms:play-services-mlkit-text-recognition:19.0.1&#39;</pre><pre>val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)<br><br>private class ParcelAnalyzer : ImageAnalysis.Analyzer {<br><br>    override fun analyze(imageProxy: ImageProxy) {<br>        val mediaImage = imageProxy.image<br>        if (mediaImage != null) {<br>            val image = InputImage.fromMediaImage(mediaImage, imageProxy.imageInfo.rotationDegrees)<br>      <br>        }<br>    }<br>}<br><br><br>val result = recognizer.process(image)<br>        .addOnSuccessListener { visionText -&gt;<br>        <br>        }<br>        .addOnFailureListener { e -&gt;<br>   <br>        }<br><br><br>val resultText = result.text<br>for (block in result.textBlocks) {<br>    val blockText = block.text<br>    val blockCornerPoints = block.cornerPoints<br>    val blockFrame = block.boundingBox<br>    for (line in block.lines) {<br>        val lineText = line.text<br>        val lineCornerPoints = line.cornerPoints<br>        val lineFrame = line.boundingBox<br>        for (element in line.elements) {<br>            val elementText = element.text<br>            val elementCornerPoints = element.cornerPoints<br>            val elementFrame = element.boundingBox<br>        }<br>    }<br>}</pre><h3>Data Validation &amp; API Integration</h3><p>After extracting the required data, the app shows it to the user for <strong>final confirmation</strong> to avoid incorrect submissions. Once confirmed, the data is sent directly to the backend API — eliminating manual entry entirely.</p><h3>The Impact</h3><p>By applying this AI-driven approach:</p><ul><li>Manual data entry was almost eliminated</li><li>Parcel processing became significantly faster</li><li>Human errors were reduced</li><li>Overall warehouse operations improved by <strong>~60%</strong></li></ul><p>What once required multiple steps and constant user interaction could now be completed with <strong>a single photo</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xT-nGfpHe2XhDGLA4eBPtw.png" /></figure><h3>Final Thoughts</h3><p>This experience reinforced an important lesson for me:<br><strong>AI doesn’t always need to be complex or futuristic — sometimes, small practical integrations create massive operational value.</strong></p><p>Bringing OCR into logistics wasn’t just a technical win; it was a real business improvement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c922c9550ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhance Jetpack Compose Performance Using Baseline Profiles]]></title>
            <link>https://medium.com/@m.alhussein.96/enhance-jetpack-compose-performance-using-baseline-profiles-bc7d02a43229?source=rss-65d7e00a2039------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc7d02a43229</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[compiler-optimization]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[baseline-profiles]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Mohammad AlHussain]]></dc:creator>
            <pubDate>Wed, 09 Oct 2024 12:14:05 GMT</pubDate>
            <atom:updated>2024-10-09T12:14:05.516Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve developed an Android app using Jetpack Compose and noticed performance issues, even in the release APK, you’re not alone. This article will guide you through the steps to improve your app’s performance using <strong>Baseline Profiles</strong> in a Q&amp;A format, simplifying the process as much as possible.</p><h4>1. Why is my Compose app rendering slowly, even after generating a release APK?</h4><p>This can be attributed to the <strong>JIT (Just-In-Time)</strong> compiler introduced in Android 7.0. The JIT compiler improves performance by compiling code at runtime but also consumes more resources initially, leading to slower performance right after installation.</p><blockquote>For more detailed information, you can refer to the official <a href="https://developer.android.com/about/versions/nougat/android-7.0#jit_aot">Android documentation on JIT compilation</a>.</blockquote><h4>2. Why have I used baseline profiler to improve performance?</h4><blockquote>While developing my Android app for a POS device, I noticed a significant performance gap between the older XML-based UI and the new Compose version. Even after making several optimizations in Compose, there were still noticeable performance issues.</blockquote><blockquote>That’s when I discovered <strong>Baseline Profiles</strong>, and after implementing them, the performance noticeably improved from the user’s perspective. Let’s dive into how you can integrate them into your project.</blockquote><h4>3. Steps to implement Baseline Profiles in your Android project</h4><h4><strong>Step 1:</strong> Update Android Gradle Plugin (AGP) to 8.2.0</h4><h4><strong>Step 2:</strong> Add the Baseline Profile Generator module</h4><p>In Android Studio, click on <strong>File &gt; New &gt; New Module</strong> and select the <strong>Baseline Profile Generator</strong>. This module will help generate baseline profiles during the build process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*jpQTtjRr6OFhsOPHdgbn8Q.png" /></figure><h4>Step 3: Modify your project-level build.gradle</h4><p>In your project-level build.gradle file, make sure to include the following line:</p><pre>alias(libs.plugins.baselineprofile) apply false</pre><h4>Step 4: Modify your app-level build.gradle</h4><p>In your app-level build.gradle, add the following dependency:</p><pre>implementation(libs.androidx.profileinstaller)</pre><blockquote>Note: I am using the toml format for managing dependencies and libraries.</blockquote><h4>Step 5: Add dependencies in the TOML file</h4><p>In your versions.toml file, add the versions and dependencies required for Baseline Profiles:</p><pre>[versions]<br>baselineprofile = &quot;1.3.0&quot;<br>profileinstaller = &quot;1.3.1&quot;<br><br>[libraries]<br>androidx-profileinstaller = { group = &quot;androidx.profileinstaller&quot;, name = &quot;profileinstaller&quot;, version.ref = &quot;profileinstaller&quot; }<br><br>[plugins]<br>baselineprofile = { id = &quot;androidx.baselineprofile&quot;, version.ref = &quot;baselineprofile&quot; }</pre><h4>Step 6: Use Android SDK 34 or higher</h4><p>Baseline Profiles require running on at least <strong>Android SDK 34</strong>. If you don’t have a physical device running this version, you can use an emulator.</p><h4>Step 7: Run the Baseline Profile Generator</h4><p>Run the <strong>Baseline Profile Generator</strong> from Android Studio, making sure you’re in the <strong>release build</strong> type. Once the process is complete, two files will be generated in:</p><pre>src/variant/generated/baselineProfiles/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/0*UpBU-XaNnQ-LOYzc.png" /></figure><p>These files contain the rules that help the Android runtime compiler optimize your app’s performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*cfa-VGZSa-wJr7gdv3_bZw.png" /></figure><h4>Step 8: Build and analyse your release APK</h4><p>After generating the baseline profile, build your release APK. You can analyse it using the APK Analyzer in Android Studio to confirm that the Baseline Profiles are included.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Aqw35VCBk9nZqxiH-UKPZw.png" /></figure><h4>4. Post-installation APK performance improvement</h4><p>After running the APK on my device, I observed a noticeable improvement in performance. However, it’s essential to understand that the app will go through two states depending on the device:</p><ul><li><strong>Quicken</strong> or <strong>Verified</strong></li><li><strong>Speed-Profiled</strong></li></ul><p>You can verify this by running the following command in the terminal:</p><pre>adb shell dumpsys package dexopt</pre><p>Look for your app’s package name, and if it’s not fully compiled, the Baseline Profile hasn’t been completely optimized yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*0VsPff8qPJFcwiIQPEmLXw.png" /></figure><h4>5. Forcing the Baseline Profile compilation</h4><p>To force your APK to compile with the Baseline Profile, run the following command in the terminal:</p><pre>adb shell cmd package compile -r bg-dexopt &lt;your-package-name&gt;</pre><p>Once successful, run the adb dumpsys command again, and you should see that the profile has moved to the <strong>Speed-Profile</strong> state.</p><h4>6. Don’t worry, it will auto-optimize</h4><p>Over time, your app will naturally shift to the <strong>Speed-Profile</strong> state based on various factors such as operating system conditions, device charge level, and more. However, forcing the compilation can ensure that users experience improved performance sooner.</p><p>For more details on force compilation, check out the official Android documentation <a href="https://developer.android.com/topic/performance/baselineprofiles/debug-baseline-profiles#force_compilation_of_baseline_profiles">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc7d02a43229" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zebra Hardware (Printers): Connect Android To Printers Guide I]]></title>
            <link>https://medium.com/@m.alhussein.96/zebra-hardware-printers-connect-android-to-printers-guide-i-7c1842ed8aa4?source=rss-65d7e00a2039------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c1842ed8aa4</guid>
            <category><![CDATA[wifi]]></category>
            <category><![CDATA[printers]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[zebra]]></category>
            <category><![CDATA[bluetooth]]></category>
            <dc:creator><![CDATA[Mohammad AlHussain]]></dc:creator>
            <pubDate>Wed, 11 Oct 2023 09:16:37 GMT</pubDate>
            <atom:updated>2023-10-11T11:24:17.985Z</atom:updated>
            <content:encoded><![CDATA[<p>Zebra devices like handheld computers are used in many industries like warehouse management, retail, transportation and logistics to scan qr code and print labels.</p><p>I came from warehouse management which is using handheld computers from zebra to scan and print and I will start talking about printers and especially how to use zebra SDK to connect to zebra printers and send files and using common features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*BxVNKeEC_uq0i0bvWwEGrg.jpeg" /></figure><blockquote>Three type of connection to printer are available (Wifi, Bluetooth (Classic, LE) and USB)</blockquote><h3>Wifi Connection</h3><h4><strong>1. Improt SDK library</strong></h4><p>First you must download the jar library and import it in android studio as libs.</p><p>you can find the sdk for printer connection in the link below:</p><p><a href="https://github.com/Al-Hussein-96/Zebra-Printer/blob/main/app/libs/ZSDK_ANDROID_API.jar">ZSDK_ANDROID_API.jar</a></p><h4>2. Add Internet permission to AndroidManifest.xml</h4><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;</pre><h4>3. Discover Wifi zebra printer by using Network Discovery from SDK.</h4><p>Here we are using callback flow to emit a list of discoveredPrinters on discovering finished as flow.</p><pre>fun getWifiZebraPrinters() = callbackFlow {<br>    NetworkDiscoverer.findPrinters(object : DiscoveryHandler {<br>        val discoveredPrinters: MutableList&lt;DiscoveredPrinter&gt; = mutableListOf()<br>        override fun foundPrinter(printer: DiscoveredPrinter) {<br>            println(printer)<br><br>            discoveredPrinters.add(printer)<br>        }<br><br>        override fun discoveryFinished() {<br>            for (printer in discoveredPrinters) {<br>                println(printer)<br>            }<br>            trySend(discoveredPrinters)<br>        }<br><br>        override fun discoveryError(message: String) {<br>            println(&quot;An error occurred during discovery : $message&quot;)<br>        }<br>    })<br>    awaitClose()<br>}</pre><h4>4. Connect to printer</h4><p>Here we will use flow builder to emit printer connection status.</p><p>We are using a WIFI Printer, so we will use TcpConnection from zebra SDK with IP and Port to establish the connection then try to open connection as below, of course we will use IO Dispatcher to work with network operation.</p><pre>fun connectToPrinter(ipWifiPrinter: WifiPrinterEntity) = flow {<br>    try {<br>        connection = TcpConnection(ipWifiPrinter.ip, ipWifiPrinter.port.toInt())<br>        emit(&quot;Connecting....&quot;)<br>        connection.open()<br>        emit(&quot;Connected....&quot;)<br><br>        println(&quot;Connection status : ${connection.isConnected}&quot;)<br>    } catch (e: Exception) {<br>        emit(&quot;Error while connecting.... ${e.message}&quot;)<br>    }<br>}.flowOn(Dispatchers.IO)</pre><h4>5. Test printer (print configuration label)</h4><p>To test the printer first we have to get a Zebra printer instance from the TCP connection we’ve made.</p><p>Then we can print the Configuration Label to check if the printer works properly</p><pre>fun testPrinter() = CoroutineScope(dispatcher).launch {<br>    if (connection.isConnected) {<br>        val zebraPrinter = ZebraPrinterFactory.getInstance(connection)<br>        zebraPrinter.printConfigurationLabel()<br>    }<br>}</pre><h3>Bluetooth Connection</h3><p>We have two types of bluetooth : classic and BLE.</p><p>Our SDK will help us to discover and connect to classic bluetooth and regarding BLE printers we will discuss later to import a new SDK jar for BLE.</p><p>After adding the SDK for zebra follow the steps below.</p><h4>1. Add bluetooth permission to AndroidManifest.xml</h4><p>We need these permission to be able to discover printers around by bluetooth.</p><blockquote>Note: don’t forget to ask for permission from users.</blockquote><pre>&lt;uses-permission<br>    android:name=&quot;android.permission.BLUETOOTH&quot;<br>    android:maxSdkVersion=&quot;30&quot; /&gt;<br>&lt;uses-permission<br>    android:name=&quot;android.permission.BLUETOOTH_ADMIN&quot;<br>    android:maxSdkVersion=&quot;30&quot; /&gt;<br>&lt;!-- required for API 23 - 30, no android:maxSdkVersion because of a potential breaking change --&gt;<br>&lt;!-- TODO: add android:maxSdkVersion on 2.0.0 --&gt;<br>&lt;uses-permission-sdk-23 android:name=&quot;android.permission.ACCESS_COARSE_LOCATION&quot; /&gt;<br>&lt;uses-permission-sdk-23 android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot; /&gt;<br>&lt;!-- API 31+ --&gt;<br>&lt;uses-permission android:name=&quot;android.permission.BLUETOOTH_CONNECT&quot; /&gt;<br>&lt;uses-permission<br>    android:name=&quot;android.permission.BLUETOOTH_SCAN&quot;<br>    android:usesPermissionFlags=&quot;neverForLocation&quot;<br>    tools:targetApi=&quot;s&quot; /&gt;</pre><h4>2. Discover Bluetooth zebra printers by using Bluetooth Discovery from SDK.</h4><p>As we used in wifi printers to discover wifi printers we will discover bluetooth printers as the code below.</p><blockquote>Note: only bluetooth classic printers will be discovered and not Bluetooth BLE (Low Energy)</blockquote><pre>fun getBluetoothZebraPrinters() = callbackFlow {<br>    BluetoothDiscoverer.findPrinters(context, object : DiscoveryHandler {<br>        val discoveredPrinters: MutableList&lt;DiscoveredPrinter&gt; = mutableListOf()<br>        override fun foundPrinter(printer: DiscoveredPrinter) {<br>            println(printer)<br><br>            discoveredPrinters.add(printer)<br>        }<br><br>        override fun discoveryFinished() {<br>            for (printer in discoveredPrinters) {<br>                println(printer)<br>            }<br>            trySend(discoveredPrinters)<br>        }<br><br>        override fun discoveryError(message: String) {<br>            println(&quot;An error occurred during discovery : $message&quot;)<br>        }<br>    })<br>    awaitClose()<br>}</pre><h4>4. Connect to bluetooth printer</h4><p>Same as Wifi printers but we have small changes in Connection instances.</p><p>So we will use BluetoothConnection from zebra SDK with Bluetooth MAC to establish the connection then try to open connection as below.</p><pre>val connection = BluetoothConnection(printer.mac)</pre><h4>5. Test printer (print configuration label)</h4><p>To test bluetooth printers we will use the same wifi printer because we will have the same instance of a zebra printer.</p><pre>fun testPrinter() = CoroutineScope(dispatcher).launch {<br>    if (connection.isConnected) {<br>        val zebraPrinter = ZebraPrinterFactory.getInstance(connection)<br>        zebraPrinter.printConfigurationLabel()<br>    }<br>}</pre><h3>BluetoothLE Connection</h3><h4>1. Add BLE SDK from zebra, you will find it in the link below.</h4><p><a href="https://github.com/Al-Hussein-96/Zebra-Printer/blob/main/app/libs/ZSDK_ANDROID_BTLE.jar">ZSDK_ANDROID_BTLE.jar</a></p><h4>2. Apply these changes to code mention before.</h4><p><strong>Instead of</strong></p><pre>BluetoothDiscoverer.findPrinters(context,..... </pre><p><strong>use</strong></p><pre>BluetoothLeDiscoverer.findPrinters(context,</pre><p><strong>And Instead of</strong></p><pre>val connection = BluetoothConnection(printer.mac)</pre><h4>use</h4><pre>val connection = BluetoothLeConnection(printer.mac,context)</pre><blockquote>Others will stay same as same code for printing.</blockquote><h3>Summary:</h3><p>Our blog was about how to discover and connect to Zebra printers fro label printing with <strong>Android Kotlin</strong>, we talked about three type of connection</p><p>WIFI , Bluetooth classic, Bluetooth LE.</p><p>and we imported two SDK from zebra to establish our connection and test the printer by printing configuration label.</p><p>you can check example code from my repository on github in the link below.</p><p><a href="https://github.com/Al-Hussein-96/Zebra-Printer/tree/main">https://github.com/Al-Hussein-96/Zebra-Printer/tree/main</a></p><p>In the next blog we will discuss further about How to send files to printer and statuses.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c1842ed8aa4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>