<?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 Burak iren on Medium]]></title>
        <description><![CDATA[Stories by Burak iren on Medium]]></description>
        <link>https://medium.com/@burakirenn?source=rss-7e7ef3b05d15------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*j7ywV4N5KT5oXH8kxRHcjQ.jpeg</url>
            <title>Stories by Burak iren on Medium</title>
            <link>https://medium.com/@burakirenn?source=rss-7e7ef3b05d15------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 17:35:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@burakirenn/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[Introduction to AR Engine]]></title>
            <link>https://medium.com/huawei-developers/introduction-to-ar-engine-e87155ecdee0?source=rss-7e7ef3b05d15------2</link>
            <guid isPermaLink="false">https://medium.com/p/e87155ecdee0</guid>
            <category><![CDATA[huawei-mobile-service]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[huawei]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[ar-engine]]></category>
            <dc:creator><![CDATA[Burak iren]]></dc:creator>
            <pubDate>Tue, 24 Nov 2020 12:30:25 GMT</pubDate>
            <atom:updated>2020-11-25T06:56:00.247Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi friends, today we will introduce to Huawei AR Engine which is developed by Huawei. But, before the AR Engine explains, we should talk about the Augmented Reality.</p><p><strong>What is Augmented Reality(AR)?</strong></p><p>Augmented reality (AR) is an interactive experience of a real-world environment where the objects that reside in the real world are enhanced by computer-generated perceptual information, sometimes across multiple sensory modalities, including visual, auditory, haptic, somatosensory and olfactory. AR can be defined as a system that fulfills three basic features: a combination of real and virtual worlds, real-time interaction, and accurate 3D registration of virtual and real objects.</p><p>If we talk about some important features:</p><ul><li>Working with Graphics, video, sound, 3D model etc.</li><li>AR technology changes the perception of reality, making it more interactive.</li><li>Combination of the real world and digitally produced elements.</li><li>The virtual content can be interacted with in real time.</li><li>Virtual objects appear fixed in space.</li></ul><p><strong>How AR is working?</strong></p><p>Augmented reality uses complex computer vision algorithms to differentiate between the physical and digital worlds. The technology involved often includes the following core features:</p><p><strong>Simultaneous localization and mapping</strong>, or SLAM technology, which is effectively a robot that creates a real-time visual map of its surroundings, constantly updating and reorienting as its home device moves.</p><p><strong>Cameras and depth tracking sensors</strong> that collect data from the surrounding area to help the device locate physical objects and generate 3D models.</p><p><strong>Processing power</strong>, as AR devices are essentially little computers that contain a CPU, GPU, RAM, flash memory, Bluetooth, WiFi, and GPS. These components enable the device to measure direction, speed, angles, and orientation.</p><p><strong>Miniature projectors</strong> to place 3D holographic images onto the view of the real-world environment.</p><p><strong>Mirrors</strong> to reflect natural and artificial light towards the camera and also to the user’s eyes. The inclusion of these reflection paths enhances image alignment, which adds to the illusion.</p><p><strong>What is Huawei AR Engine?</strong></p><p>HUAWEI AR Engine is a platform for building augmented reality (AR) apps on Android smartphones. It is based on the HiSilicon chipset, and integrates AR core algorithms to provide basic AR capabilities such as motion tracking, environment tracking, body tracking, and face tracking, allowing your app to bridge virtual world with the real world, for a brand new visually interactive user experience.</p><p>AR Engine continuously tracks the device location and pose to improve its perception of the real world, in order to provide motion tracking and environment tracking abilities. Specifically, AR Engine identifies feature points in a space through the device camera, tracks the movement of these points, and integrates these changes with the data reported by the inertial sensor on the device, to continuously track the device location and pose. In addition, it recognizes such planes as floors or walls, and estimates the lighting intensity around them when identifying the feature points.</p><p>Currently, AR Engine provides three types of capabilities, including motion tracking, environment tracking, and human body and face tracking.</p><p><strong>Motion Tracking</strong></p><p>HUAWEI AR Engine continuously tracks changes in the location and pose of the device relative to the surrounding environment, and establishes a cohesive geometric space that bridges the virtual digital world and the real world. Motion tracking currently supports motion tracking and hit test.</p><p><strong>Environment Tracking</strong></p><p>HUAWEI AR Engine also tracks the illumination, plane, image, object, surface, and other environmental information, to assist your apps in integrating virtual objects into the physical world in the same manner as in the real scene. Environment tracking currently supports the following capabilities: illumination estimation, plane detection, image tracking, and environment mesh.</p><p><strong>Human Body and Face Tracking</strong></p><p>HUAWEI AR Engine tracks real-time information related to human bodies, faces, and hand gestures to assist your apps in implementing natural interactions between users and virtual objects.</p><p><strong>Huawei AR Engine Structure</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oGxNsLcTBnFlYnmFTbmOPw.png" /></figure><p><strong>Supported Devices</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8iAat_1KXQUuQDJYk2Y-bg.png" /></figure><p><strong>AR Engine Versions</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mwREbsxmSUUE5VwUXZ-_QA.png" /></figure><p><strong>AR Engine Development Process</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HFBCIFUTV4a0vRdVMq0CXg.png" /></figure><p><strong>Example Codes For Face Comparision</strong></p><p>Check whether AR Engine has been installed on the current device. If yes, the app can run properly. If not, the app automatically redirects the user to AppGallery to install AR Engine. The sample code is as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27d36c8325e42894895365b4a0bcdfe8/href">https://medium.com/media/27d36c8325e42894895365b4a0bcdfe8/href</a></iframe><p>Set the AR scene parameters and start the AR scene.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d8a87e4c2a726ad18d3dd7b2b5c8168/href">https://medium.com/media/8d8a87e4c2a726ad18d3dd7b2b5c8168/href</a></iframe><p>The calculation results of AR Engine can be obtained by frame. You can call ARSession.update in OnDrawFrame to get ARFrame, and call ARSession.getAllTrackables(ARPlane.class) to obtain the AR plane captured by AR Engine.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8218dc1b92848b55a759ae2e0a3c1ef9/href">https://medium.com/media/8218dc1b92848b55a759ae2e0a3c1ef9/href</a></iframe><p>After the plane is captured, click the plane on the device screen to trigger the hit test (hitTest), and add the hit result as an anchor (ARAnchor) to the ARSession for continuous tracking.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e097ce66ddc0e162ca8e9c75eb1d6de/href">https://medium.com/media/4e097ce66ddc0e162ca8e9c75eb1d6de/href</a></iframe><p><strong>Hand Gesturing</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PkGPu12WlyInEqHMtWkIqw.png" /></figure><p><strong>Conclusion</strong></p><p>I have tried to explain what is AR Engine with its features and examples. See you in our other article, bye :)</p><p><strong>References</strong></p><p><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/introduction-0000001050130900">Document</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e87155ecdee0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/introduction-to-ar-engine-e87155ecdee0">Introduction to AR Engine</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to HiAI Engine?]]></title>
            <link>https://medium.com/huawei-developers/introduction-to-hiai-engine-cf9f24d52ce1?source=rss-7e7ef3b05d15------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf9f24d52ce1</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[smart]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[hiai]]></category>
            <category><![CDATA[huawei]]></category>
            <dc:creator><![CDATA[Burak iren]]></dc:creator>
            <pubDate>Mon, 23 Nov 2020 14:05:32 GMT</pubDate>
            <atom:updated>2020-11-24T11:10:22.648Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to HiAI Engine</h3><p>Hi friends, today we will introduce to Huawei Artificial Intelligence which is developed by Huawei. But, before the HiAI Engine explains, we should talk about the Artificial Intelligence.</p><h4>What is Artificial Intelligence (AI)?</h4><p>Artificial intelligence (AI), is intelligence demonstrated by machines, unlike the natural intelligence displayed by humans and animals and refers to the simulation of human intelligence in machines that are programmed to think like humans and mimic their actions.</p><ul><li>The goals of artificial intelligence include learning, reasoning, and perception.</li><li>AI is being used across different industries including finance and healthcare.</li></ul><h4>What is Huawei HiAI ?</h4><p>HiAI is Huawei’s AI computing platform. HUAWEI HiAI is a mobile terminal–oriented artificial intelligence (AI) computing platform that constructs three layers of ecology: service capability openness, application capability openness, and chip capability openness. The three-layer open platform that integrates terminals, chips, and the cloud brings more extraordinary experience for users and developers. These 3-layer open capabilities are;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VkvMVjWLDiGNhpayyShSPg.png" /></figure><ul><li><strong>HUAWEI HiAI Foundation(Chipset) : </strong>Accelerates the transformation and migration of existing models, and optimizes chipset performance through heterogeneous scheduling and NPU acceleration. Achieve optimal energy efficiency and breakthrough performance.</li><li><strong>HUAWEI HiAI Engine (Device) : </strong>Integrates various AI capabilities into apps, making apps more intelligent and powerful.</li><li><strong>HUAWEI HiAI Service (Cloud) :</strong> A fertile ground for smart all scenario digital services. Service capabilities — connecting users with your services.</li></ul><p>Today we will focus more on HiAI Engine.</p><p><strong>What is HUAWEI HiAI Engine?</strong></p><p>HUAWEI HiAI Engine opens application capabilities, and easily integrates a plurality of AI capabilities and Apps, making the Apps more intelligent and powerful.</p><p>The open application capabilities are as follows:</p><ul><li><strong>Computer Vision (CV) Engine : </strong>CV is the capabilities by which computers simulate the human visual system to sense the ambient environment, and determine, recognize, and understand the composition of space. The capabilities include image super resolution, facial recognition, and object recognition.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yRXOqDpHHN2uMEgS2BmNAg.png" /></figure><ul><li><strong>Automatic Speech Recognition (ASR) Engine : </strong>ASR converts human voice into text, to facilitate further parsing and understanding by computers. The capabilities include speech recognition, speech conversion, and text-to-speech (TTS). (Just open for China yet)</li><li><strong>Natural Language Understanding (NLU) Engine : </strong>NLU is combined with the ASR engine, to enable Apps to understand human voice or text, thereby performing communication or natural actions. The capabilities include word segmentation, text entity recognition, emotive tendency analysis, and machine translation. (Just open for China yet)</li></ul><p>The features of the HiAI Engine are:</p><ul><li><strong>Scene Detection : </strong>Scene detection can quickly classify images by identifying the type of scene to which image content belongs, including animals, green plants, food, buildings, and automobiles. Scene detection can also add smart classification labels to images, facilitating smart album generation and image category management.</li><li><strong>Document Converter : </strong>Document converter enables apps to convert document images into electronic documents conveniently, such as PPT files. It can recognize documents and the texts in images, and return the recognized content to the client, which will restore the results into a PPT file.</li><li><strong>Face Detection : </strong>Face detection detects human faces in images, and maps the faces according to a high-precision rectangular grid. It can be used as the key module for screen unlocking or locking apps, as well as a wide range of scenarios that require facial recognition. Specific locations on a human face can be beautified, based on their positioning relative to key facial features. This API can be applied in features such as face unlock, face clustering, and facial beautification.</li><li><strong>Facial Comparison</strong>: Facial comparison recognizes and extracts key facial features, performs high-precision comparisons of human faces, provides confidence scores, and determines whether the same person appears across different images. Cutting-edge facial comparison technology intelligently categorizes and manages photos. An intelligent image recognition algorithm ensures accurate facial recognition, and enables apps to provide an enhanced user experience.</li><li><strong>Body Pose Estimation : </strong>The key skeletal features are important for describing human posture and predicting human behavior. Therefore, the recognition of key skeletal features is the basis for a diversity of computer vision tasks, such as motion categorizations, abnormal behavior detection, and auto-navigation. In recent years, improved skeletal feature recognition has been widely applied to the development of deep learning technology, especially domains relating to computer vision.</li></ul><p>Pose estimation mainly detects key human body features such as joints and facial features, and provides skeletal information based on such features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*b4LbXr3JGb2XCY7O3xCaeQ.png" /></figure><ul><li><strong>Code Recognation : </strong>Code recognition identifies the QR codes and bar codes to obtain the contained information, based on which the service framework is provided.</li></ul><p>This API can be used to parse QR codes and bar codes in 11 scenarios including Wi-Fi and SMS. It provides effective code detection and result-based service provision capabilities.</p><h4>Example Codes For Face Comparision</h4><p><em>Before the beginning development, you have to add huawei-hiai-asr.aar and huawei-hiai-vision.aar libraries to you project.</em></p><p>Run the following commands to add the classes related to facial comparison to the project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1d794d5ba8c2d3c06dee3cceff3be80/href">https://medium.com/media/f1d794d5ba8c2d3c06dee3cceff3be80/href</a></iframe><p>Perform initialization by using the <strong>VisionBase</strong> static class, to asynchronously obtain a connection to the service.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/978f2d279190aff634cf783c7f4ad2cf/href">https://medium.com/media/978f2d279190aff634cf783c7f4ad2cf/href</a></iframe><p>Define a facial comparison instance, and use the <strong>context </strong>of this project as the input parameter. Then, define <strong>VisionImage </strong>and transfer the Bitmap image to be detected. Create <strong>FaceCompareConfiguration </strong>and set the required <strong>VisionTextConfiguration</strong>. At last, Call <strong>faceCompare </strong>to obtain the result.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1a260673841b694fe0dd67266d794d2/href">https://medium.com/media/a1a260673841b694fe0dd67266d794d2/href</a></iframe><p>The <strong>isSamePerson </strong>field in <strong>mFaceCompareResult </strong>indicates whether the same person is appearing in the photos. <strong>True </strong>indicates yes, while <strong>False </strong>indicates not. The <strong>score </strong>is a floating-point number ranging from 0–1, indicating the confidence score.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c9fb0e0d24fce265537e21cf16c937f/href">https://medium.com/media/7c9fb0e0d24fce265537e21cf16c937f/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*H7Oy7NQ41eG5vzO1ZsndcQ.png" /></figure><p><strong>Conclusion</strong></p><p>I have tried to explain what is HiAi with its features and examples. See you in our other article, bye :)</p><p><strong>References</strong></p><p><a href="https://developer.huawei.com/consumer/en/hiai#Engine/">HiAI - HiAI IDE - HUAWEI Developer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf9f24d52ce1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/introduction-to-hiai-engine-cf9f24d52ce1">Introduction to HiAI Engine?</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stateful Android Apps with MVI Architecture (MODEL — VIEW — INTENT)]]></title>
            <link>https://medium.com/huawei-developers/stateful-android-apps-with-mvi-architecture-model-view-intent-d106b09bd967?source=rss-7e7ef3b05d15------2</link>
            <guid isPermaLink="false">https://medium.com/p/d106b09bd967</guid>
            <category><![CDATA[mvi]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mvvm]]></category>
            <category><![CDATA[render]]></category>
            <category><![CDATA[state]]></category>
            <dc:creator><![CDATA[Burak iren]]></dc:creator>
            <pubDate>Thu, 12 Nov 2020 06:53:45 GMT</pubDate>
            <atom:updated>2020-11-13T07:43:38.382Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Stateful Android Apps With MVI (MODEL — VIEW — INTENT)</strong></h3><p>There are a lot of architecture pattern (like MVC, MVP, MVVM) for android but today we will talk about MVI.</p><p>I will walk you through,</p><ul><li>What is MVI architecture?</li><li>How does the MVI work?</li><li>Advantages and Disadvantages of MVI</li><li>Creating a Project with MVI architecture</li></ul><h3>What is MVI architecture?</h3><p>MVI is a <strong>Reactive Architecture Pattern</strong> which is short for Model -View-Intent. It introduces two new concepts: <strong>the intent</strong> and<strong> the state</strong>. UI might have different states — <em>Loading State, Fetch Data State, Error State, User button submit state etc.</em></p><p>Consequently, we can say that the following three functions create the main components of MVI architecture:</p><ul><li><strong>Model </strong>represents the state (data display after fetch, user interaction with any button, loading states during fetch the data) of the UI . Creating new states for each situation. Our View renders everything that the model/state contains. Every time a new immutable model is created which is then observed by the view. Our model object, which tells View what to display on the screen.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c198d2c2c28f428d915413ab4e7adae2/href">https://medium.com/media/c198d2c2c28f428d915413ab4e7adae2/href</a></iframe><ul><li><strong>View </strong>is represented by an interface which defines a set of user actions (intents) as Observables and a render(ViewState) method. view() is a function that takes a new state and defines the display logic inside of it.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70af58c9c4c0c9271a33f128c3cae382/href">https://medium.com/media/70af58c9c4c0c9271a33f128c3cae382/href</a></iframe><ul><li><strong>Intent </strong>is not android.content.Intent :).The intent simply describes an intention. We will be sending models as action to the Intents which can load or show it through Views. This function takes the input or action, or command generated by the user (i.e. UI events, like click events) and translate it to “something” that will be passed as parameter to <strong>model()</strong> function.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc667da2476676985bdd206b66ff13b7/href">https://medium.com/media/fc667da2476676985bdd206b66ff13b7/href</a></iframe><h3>How does it work?</h3><p>In Model-View-Intent architecture, view exposes view-events (user input/action) and observes model for view-state changes. We process view-events and convert them into respective intent and pass it to the model. The model layer creates a new immutable view-state using intent and previous view-state. So, this way it follows the Unidirectional Data Flow principle i.e. data flows only in one direction: View &gt; Intent &gt; Model &gt; View.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*u6DY_91Uu6RhwPfaeftggQ.png" /></figure><p>The user interacts with the UI like User hits any button on the screen which can also be called User’s Intention to interaction the screen. This Intent brings about change in State of the screen. This change can occur via any kind of background logic, but the most important thing is that any change in this state has to happen only by firing an Intent. This new State is rendered on View and this newly updated View is shown to the User.</p><h3>Advantages and Disadvantages of MVI</h3><p>Generally, MVI gives more guarantees about what happens in the app because changing state happens in a single transaction at a time (usually through copy method of state data class).</p><p>This architecture really forces you to think about how you model the users interactions and the possible states of the View, and this can be highly beneficial.</p><p>There’s a lot of separation at every step, and this makes every part extremely easy to test. Mappings from Intent to Action, the Reducer logic, the Processor… all of these components have very few, tightly defined responsibilities and that makes it super easy to write unit tests at every stage. If you’re a TDD sort of person, this architecture lends itself well to that. This also makes MVI extremely predictable.</p><h3><strong>Conclusion</strong></h3><p>You can find detail of MVI architecture sample on my github project. I will update it asap.</p><p><a href="https://github.com/burakiren/MVI-Architecture-Example">burakiren/MVI-Architecture-Example</a></p><p>References:</p><p><a href="http://hannesdorfmann.com/android/mosby3-mvi-1">Reactive Apps with Model-View-Intent - Part1 - Model</a></p><p>We will continue with the detail of MVI architecture. Stay with me :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d106b09bd967" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/stateful-android-apps-with-mvi-architecture-model-view-intent-d106b09bd967">Stateful Android Apps with MVI Architecture (MODEL — VIEW — INTENT)</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Differences and Advantages of Hilt, Dagger2, Koin — 1]]></title>
            <link>https://medium.com/huawei-developers/differences-and-advantages-of-hilt-dagger2-koin-1-3af44e9a0722?source=rss-7e7ef3b05d15------2</link>
            <guid isPermaLink="false">https://medium.com/p/3af44e9a0722</guid>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[dagger-2]]></category>
            <category><![CDATA[koin]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[dagger-hilt]]></category>
            <dc:creator><![CDATA[Burak iren]]></dc:creator>
            <pubDate>Sun, 11 Oct 2020 20:14:54 GMT</pubDate>
            <atom:updated>2020-11-04T08:10:50.784Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Differences and Advantages of Hilt, Dagger2, Koin — 1</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QIgSokPpO1DR3HnUy39aPA.png" /></figure><p>Hello friends, in this article, we will introduce the subject of dependency injection for Android development, as well as discuss the advantages and differences.</p><blockquote><strong>What is DI(Dependency Injection)?</strong></blockquote><p>Dependency Injection, represented by the letter at the end of the principles abbreviated as SOLID, is a principle that greatly helps programmers. Dependency Injection is passing dependency to other objects or framework( dependency injector). It makes also testing easier.</p><p>This technique has many benefits here I’m just listing the most important ones:</p><ul><li>decoupling the creation of object</li><li>ability to replace dependencies (eg: Wheel, Battery) without changing the class that uses it(Car)</li><li>promotes “Code to interface not to implementation” principle</li><li>ability to create and use mock dependency during test</li><li>makes our code reusable and clean</li></ul><p>Now that we know about the basic concepts of dependency injection we will take a look at the different solutions and frameworks for dependency injection in Android.</p><blockquote><strong>DAGGER -2</strong></blockquote><p>Dagger 2 is an open source Dependency Injection framework. It was developed by the Square company and then forked by Google and is still being developed. It is called Dagger because it uses the Directed Acyclic Graph structure.</p><p>By finding the class that requests dependency in the code, it determines who provides the desired dependency and receives the required dependency from the provider and transmits it to the requester.</p><p><strong>What are the main components of Dagger2?</strong></p><p><strong>Component : </strong>@Component annotation takes a list of modules as an input. The component is used to connect objects to their dependencies, typically by use of overridden inject() methods. In order to use the component, it must be accessible from the parts of the app that need injection.</p><p><strong>Module</strong> : The @Module annotation tells Dagger that the EtcModule class will provide dependencies for a part of the application. It is normal to have multiple Dagger modules in a project, and it is typical for one of them to provide app-wide dependencies.</p><p><strong>Provides : </strong>The @Provides annotation tells Dagger that the method provides a certain type of dependency</p><p><strong>Singleton</strong>: It tells Dagger that there should only be a single instance of that dependency.</p><p><strong>Inject</strong> : The @Inject annotation tells Dagger that you want it to do an injection of the dependency field.</p><blockquote>What <a href="http://twitter.com/inject">@inject</a> needs comes from @ Module, via @Component</blockquote><blockquote><strong>KOIN</strong></blockquote><p>Koin is a pragmatic lightweight DSL dependency injection framework for Kotlin. Koin is easy, simple &amp; well documented. It is perfect for encapsulated feature/library modules.</p><p><em>Koin is based around its DSL which consists of these keywords:</em></p><p><strong>startKoin()</strong> — call module to start it in application</p><p><strong><em>module { }</em></strong><em> — create a Koin module or a submodule (inside a module)</em></p><p><strong><em>factory { }</em></strong><em> — provide a factory bean definition</em></p><p><strong><em>single { }</em></strong><em> — provide a bean definition</em></p><p><strong><em>get() </em></strong><em>— resolve a component dependency (eager)</em></p><p><strong><em>inject()</em></strong><em> — resolve a component dependency in Android components runtime</em></p><p><strong><em>bind</em></strong><em> — additional Kotlin type binding for given bean definition</em></p><p><strong><em>getProperty()</em></strong><em> — resolve a property</em></p><blockquote><strong>DAGGER HILT</strong></blockquote><p>The new <a href="https://developer.android.com/training/dependency-injection/hilt-android">Hilt</a> library defines a <strong>standard way </strong>to do DI in your application by providing containers for every Android class in your project and managing their lifecycles <em>automatically</em> for you.</p><p>Hilt is currently in <em>alpha </em>but it’s already quite powerful.</p><p>But in Hilt, we don’t need to create a component, include every module, and build for generating DaggerAppComponent class.</p><pre>@HiltAndroidAppclass <br>ExampleApp: Application(){<br>}</pre><p>In Hilt, we don’t have to write the ViewModelFactory and ViewModelModule. Instead, Hilt provides @ViewModelInject annotation and @Assisted annotation for SavedStateHandle.</p><pre>class MainViewModel @ViewModelInject constructor(  <br>   private val mainRepository: MainRepository,  <br>   @Assisted private val saveState: SavedStateHandle) : ViewModel(){ </pre><pre>}</pre><p>In Hilt, we don’t need to write those annotations and ActivityModule. Instead, Hilt provides a @AndroidEntryPoint annotation.</p><pre>@AndroidEntryPointclass <br>MainActivity : AppCompatActivity() {<br>}</pre><p><strong>What are the main components of Hilt?</strong></p><p><strong>@HiltAndroidApp</strong>: We need to apply this annotation to our application class, which triggers the code generation and creates the base component.</p><p><strong>@AndroidEntryPoint</strong>: Hilt creates a dependency container to the Android component that it was assigned so it can inject the dependencies.</p><p><strong>@Module </strong>: This is used on the classes that create the objects of dependency classes (for the classes that you don’t own — for example, third-party library classes like OkHttp or Retrofit).</p><p><strong>@InstallIn</strong> : The Hilt module class should also be annotated with @InstallIn to specify the scope of the module. For example, if we annotate the module with @InstallIn(ActivityComponent::class), then the module will bind to the activity lifecycle.</p><p><strong>@Provides</strong> : This is used on the methods that are inside the module class and provides the dependency objects.</p><blockquote><strong>Conclusion</strong></blockquote><p>In this posting, we explored the main featues between Hilt , Koin and Dagger-2. In the other article, we will continue the advantages between the sample codes and each other.</p><p>For more details, please check these useful<strong> references</strong> :</p><ul><li><a href="https://en.wikipedia.org/wiki/Dependency_injection">Dependency injection - Wikipedia</a></li><li><a href="https://dagger.dev/">Dagger</a></li><li><a href="https://insert-koin.io/">Koin - The Kotlin Dependency Injection Framework</a></li></ul><p><a href="https://developer.android.com/training/dependency-injection/hilt-android">https://developer.android.com/training/dependency-injection/hilt-android</a></p><p>Thanks,</p><p>Have a nice day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3af44e9a0722" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/differences-and-advantages-of-hilt-dagger2-koin-1-3af44e9a0722">Differences and Advantages of Hilt, Dagger2, Koin — 1</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Architecture Patterns Part 1: Model-View-ViewModel]]></title>
            <link>https://burakirenn.medium.com/android-architecture-patterns-part-1-model-view-viewmodel-14ddefb6e8d7?source=rss-7e7ef3b05d15------2</link>
            <guid isPermaLink="false">https://medium.com/p/14ddefb6e8d7</guid>
            <category><![CDATA[viewmodel]]></category>
            <category><![CDATA[livedata]]></category>
            <category><![CDATA[mvvm]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[architectural-components]]></category>
            <dc:creator><![CDATA[Burak iren]]></dc:creator>
            <pubDate>Wed, 11 Sep 2019 19:53:24 GMT</pubDate>
            <atom:updated>2019-09-11T19:53:24.706Z</atom:updated>
            <content:encoded><![CDATA[<p>Mvvm is an architectural pattern for seperating program logic and user interface controls. It consist 3 mainly part: Model, View, View Model.</p><h4>Model</h4><p>Model represents the business objects that encapsulate the data and behavior of application domain. It usually sends the data to the ViewMode l.If you are building an application for finding flights, your application domain model includes classes like flight, location, time.</p><h4>View</h4><p>View is the collection of visible elements, which also receives user input. This includes user interfaces (<a href="https://searchmicroservices.techtarget.com/definition/user-interface-UI">UI</a>), animations and text. Sends data only to ViewModel.</p><h4>ViewModel</h4><p>ViewModel provides communication between model and View. It is a class with properties that represent the state of the view and methods that implement the logic behind the view.</p><p>The following diagram shows MVVM components and basic interactions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Lk6ilXOyEVRoTnPss-5zvw.png" /></figure><p>The ViewModel is always created in close relation to a specific scope, either an Activity or Fragment. The scope is retained as long as the Activity or Fragment is alive. In practical terms, the ViewModel reconnects with the view after configuration changes, maintaining itself until the main view is destroyed. According to the official documentation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*LIL7o7GS8eIn-JYTYBaW1w.jpeg" /></figure><p>There are two ways to implement a ViewModel. The standard one is to extend the class, providing a no-argument constructor. This is the easiest way, but it doesn&#39;t work well with Dependency Injection.</p><pre>class MainViewModel : ViewModel() {<br>    init {<br>        // initialize some behavior<br>    }<br><br>    fun getData() : LiveData&lt;String&gt; {<br>        // get some data<br>    }<br><br>    override fun onCleared() {<br>        super.onCleared()<br>        // called before its destruction<br>    }<br>}</pre><p>In another article, we will learn how to use Mvvm with LiveData on an example.</p><p>See you later :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14ddefb6e8d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dagger 2 on Android — 1]]></title>
            <link>https://burakirenn.medium.com/dagger-2-on-android-1-461ed55f9ca4?source=rss-7e7ef3b05d15------2</link>
            <guid isPermaLink="false">https://medium.com/p/461ed55f9ca4</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[dagger-2]]></category>
            <category><![CDATA[architecture-components]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <dc:creator><![CDATA[Burak iren]]></dc:creator>
            <pubDate>Sat, 07 Sep 2019 17:01:20 GMT</pubDate>
            <atom:updated>2019-09-09T17:57:41.352Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://proandroiddev.com/dagger-2-on-android-the-simple-way-f706a2c597e9">Dagger 2 on Android</a> — 1</h3><p><a href="https://github.com/google/dagger">Dagger</a>, is a Dependency Injection library developed by Square. Currently being developed by Google. Dependency Injection is passing dependency to other objects or framework( dependency injector). Dependency injection makes testing easier. The injection can be done through constructor.</p><p>To use the Dagger library in your Android project, you must first add the following dependencies.</p><pre>implementation &#39;com.google.dagger:dagger:2.16&#39; <br>annotationProcessor &#39;com.google.dagger:dagger-compiler:2.16&#39;</pre><p>First, I will explain the annotations used in Dagger.</p><p>Suppose we have a structure like this.</p><pre>public class Picture {<br><br>    private Brush brush;<br>    private CanvasPaper paper;<br>    private Paint paint;</pre><pre>    @Inject<br>    public Picture(Brush brush, CanvasPaper paper, Paint paint) {<br>        this.brush = brush;<br>        this.paper = paper;<br>        this.paint = paint; <br>   }<br><br>    // getters and setters<br>}</pre><p>When we want to use Picture class, we have to create all the objects.</p><p><strong>Dagger uses the standard JSR-330 annotations</strong> in many places, one being <em>Inject.</em></p><p>Next, we’ll implement the code to perform the injection. More specifically, we’ll create:</p><ul><li>a <strong>module</strong>, which is a class that provides or builds the objects’ dependencies, and</li><li>a <strong>component</strong>, which is an interface used to generate the injector</li></ul><h4>Inject</h4><p>So how do we call the instance (object) of the classes we want to use? For this we will use <strong>Inject</strong> annotation.</p><p>We use Inject annotation to invoke instances of classes that are automatically generated by Dagger 2, which we specify with the annotation provide in our module.</p><pre>public class Brush  {</pre><pre>    @Inject<br>    public Brush(){<br>    }<br>}</pre><pre>public class CanvasPaper  {</pre><pre>    @Inject<br>    public CanvasPaper(){<br>    }<br>}</pre><pre>public class Paint  {</pre><pre>    @Inject<br>    public Paint(){<br>    }<br>}</pre><h4>Module</h4><p>Tells the Dagger container that this class is a module. The Injects parameter specifies the class (s) whose dependencies are to be injected with this module.</p><p>To create a module, <strong>we need to annotate the class with the <em>@Module </em>annotation</strong>. This annotation indicates that the class can make dependencies available to the container:</p><pre>@Module<br>public class PictureModule {<br>    @Provides<br>    public Brush provideBrush() {<br>        return new Brush();<br>    }<br><br>    @Provides<br>    @Singleton<br>    public CanvasPaper provideCanvas() {<br>        return new CanvasPaper();<br>    }</pre><pre>    @Provides<br>    public Paint providePaint() {<br>        return new Paint();<br>    }</pre><pre>}</pre><h4>Provides</h4><p>The classes we want to use are specified in this annotation. Using this annotation, Dagger 2 produces the class for us when we need it. We need to add the @Provides annotation on methods that construct our dependencies.</p><h4>Singleton</h4><p><em>@Singleton</em> (and any other scope annotation) makes your class a single instance in your dependencies graph (it means that this instance will be &quot;singleton&quot; as long as Component object exists).</p><p>In short — everytime you’re injecting @Singleton annotated class (with @Inject annotation) it will be the same instance as long as you inject it from the same Component.</p><h4>Component</h4><p>In the class that has the <a href="http://twitter.com/Component">@Component</a> annotation, we define which classes take dependencies.</p><p>This is the class that will generate Picture instances, injecting dependencies provided by PictureModule.</p><p>Simply put, we need a method signature that returns a <em>Picture </em>and <strong>we need to mark the class with the <em>@</em></strong>Component<strong><em> </em>annotation</strong>:</p><pre>@Singleton<br>@Component(modules = PictureModule.class)<br>public interface PictureComponent {<br>    Picture buildPicture();<br>}</pre><p>Notice how we passed our module class as an argument to the <em>@Component</em> annotation. <strong>If we didn’t do that, Dagger wouldn’t know how to build the picture’s dependencies.</strong></p><p>These are the basic components of Dagger. In the next lesson we will continue with an example application.</p><p>See you again, good day :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=461ed55f9ca4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android MinifyEnabled, Obfuscation and Shrink]]></title>
            <link>https://burakirenn.medium.com/android-minifyenabled-obfuscation-and-shrink-9edcb4c6ffa4?source=rss-7e7ef3b05d15------2</link>
            <guid isPermaLink="false">https://medium.com/p/9edcb4c6ffa4</guid>
            <category><![CDATA[obfuscation]]></category>
            <category><![CDATA[minifyenabled]]></category>
            <category><![CDATA[proguard]]></category>
            <category><![CDATA[shrink]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Burak iren]]></dc:creator>
            <pubDate>Sun, 07 Jul 2019 20:26:31 GMT</pubDate>
            <atom:updated>2019-07-19T10:30:11.477Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dNzNZ5Fc0nbIoKfPGI0ldA.png" /></figure><p>Hello there,<br>One of the issues we should be aware of when developing an Android application is code security as well as the size of the project we create. By decompiling our project with 3rd party applications, intruders can clone it or, seizing the rest ser-vices, listen to and manipulate the outgoing requests. In today’s topic, we will learn how to ensure code reliability as well as delete unused resources in our project re-ducing its size as much as possible.</p><p>For starters we can use Proguard. ProGuard is a tool that helps us minimize, hide and optimize our code. It can be enabled by using the <strong>minifyEnabled</strong> option for re-lease or debug types. If we want to define Proguard as default, we can add the fol-lowing lines of code to the app gradle.</p><pre>android <strong>{</strong><br>   buildTypes <strong>{</strong><br>      dev <strong>{</strong><br>          minifyEnabled <strong>true</strong>  <em>// enables ProGuard</em><br>          proguardFiles <strong>getDefaultProguardFile(</strong>&#39;proguard-android.txt&#39;<strong>),</strong> &#39;proguard-rules.pro&#39;<br>      <strong>}</strong><br><strong>}</strong></pre><p><em>** The </em><strong><em>minifyEnabled</em></strong><em> property does not work when </em><strong><em>Instant Run</em></strong><em> is on</em></p><p>By default, if you run proguard this way, the source code gets compressed, but the ob-fuscation process is still incomplete, meaning our code is not yet fully secure.<br>The Android SDK comes with Proguard built in and the default settings are specifiedin proguard-android.txt. The Proguard-rules.pro file is the file you need to configure.</p><h4>shrinkResources:</h4><p>Reduces application size by removing unused alternative sources (images, xml, and so on) and combining duplicate resources.</p><pre>android {<br>    ...<br>    buildTypes {<br>        release {<br>            <strong>shrinkResources true</strong><br>            minifyEnabled true<br>            proguardFiles getDefaultProguardFile(&#39;proguard-android.txt&#39;),proguard-rules.pro&#39;<br>        }<br>    }<br>}</pre><h3>Obfuscation options</h3><blockquote><em>-keep:</em></blockquote><p>The various <a href="https://www.guardsquare.com/en/products/proguard/manual/usage#keep">-keep</a> options for shrinking and obfuscation may seem a bit confusing at first, but there’s actually a pattern behind them. The following table summarizes how they are related:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iu-Px9jKqYqgDDjOV3YtfQ.png" /></figure><blockquote>-dontobfuscate</blockquote><p>Specifies not to obfuscate the input class files. By default, ProGuard obfuscates the code: it assigns new short random names to classes and class members. It removes internal attributes that are only useful for debugging, such as source files names, variable names, and line numbers.</p><blockquote>-dontshrink</blockquote><p>Specifies not to shrink the input. By default, ProGuard shrinks the code: it removes all unused classes and class members. It only keeps the ones listed by the various <a href="https://www.guardsquare.com/en/products/proguard/manual/usage#keep">-keep</a> options, and the ones on which they depend, directly or indirectly. It also applies a shrinking step after each optimization step, since some optimizations may open up the possibility to remove more classes and class members.</p><h4>Common Proguard Usages</h4><blockquote>These options shrink, optimize, and obfuscate the single Android activitycom.example.MyActivity:</blockquote><pre>-keep public class com.example.MyActivity</pre><blockquote>If you’re using Google’s optional License Verification Library, you can obfuscate its code along with your own code. You do have to preserve itsILicensingService interface for the library to work:</blockquote><pre>-keep public interface <strong>com</strong>.<strong>android</strong>.<strong>vending</strong>.<strong>licensing</strong>.<strong>ILicensingService</strong></pre><blockquote>If you’re using the Android Compatibility library, you should add the following line, to let ProGuard know it’s ok that the library references some classes that are not available in all versions of the API:</blockquote><pre>-dontwarn android.support.**</pre><blockquote>These options shrink, optimize, and obfuscate a serialization code.</blockquote><pre>-keepclassmembers class * implements <strong>java</strong>.<strong>io</strong>.<strong>Serializable</strong> {<br>    static final long serialVersionUID;<br>    private static final java.io.ObjectStreamField[] serialPersistentFields;<br>    private void <strong>writeObject</strong>(java.io.ObjectOutputStream);<br>    private void <strong>readObject</strong>(java.io.ObjectInputStream);<br>    java.lang.Object <strong>writeReplace</strong>();<br>    java.lang.Object <strong>readResolve</strong>();<br>}</pre><blockquote><em>Auxiliary resources</em></blockquote><ul><li><a href="https://www.guardsquare.com/en">Guardsquare | Mobile Application Protection</a></li><li><a href="https://github.com/krschultz/android-proguard-snippets/tree/master/libraries">krschultz/android-proguard-snippets</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9edcb4c6ffa4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>