<?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 Luyen Ninh on Medium]]></title>
        <description><![CDATA[Stories by Luyen Ninh on Medium]]></description>
        <link>https://medium.com/@luyenninh?source=rss-768f9aadc213------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*zCc96ZEjz0cytQ8vIG2Y8A.jpeg</url>
            <title>Stories by Luyen Ninh on Medium</title>
            <link>https://medium.com/@luyenninh?source=rss-768f9aadc213------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 14:16:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@luyenninh/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[Clean Architecture Android]]></title>
            <link>https://medium.com/culi-tech-viet/clean-architecture-android-64bb3af29478?source=rss-768f9aadc213------2</link>
            <guid isPermaLink="false">https://medium.com/p/64bb3af29478</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[mvvm]]></category>
            <category><![CDATA[achitectural-patterns]]></category>
            <category><![CDATA[uml]]></category>
            <dc:creator><![CDATA[Luyen Ninh]]></dc:creator>
            <pubDate>Mon, 23 Mar 2020 02:40:40 GMT</pubDate>
            <atom:updated>2020-03-23T03:05:57.528Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*wOmAHDN_zKZJns9YDjtrMw.jpeg" /><figcaption>The clean architecture</figcaption></figure><p>Trong quá khứ chúng ta có thể đã được học rất nhiều <strong><em>Software Architecture </em></strong>từ thời còn ngồi trên ghế nhà trường. Nhưng gần đây chúng ta đã được tiếp cận với một số kiến trúc mới như MVVM, MVP, VIPER và nhiều mô hình khác.</p><p><em>Nhưng trong bài viết này ta sẽ không đi vào giải thích các mô hình kiến trúc trên. Ta sẽ cùng nhau đi giải thích cho câu hỏi: Tại sao lại phải sử dụng các kiến trúc vào trong project, và làm sao để có được một kiến trúc tốt nhất.</em></p><h4>Một kiến trúc tốt là như thế nào?</h4><p>Một kiến trúc đủ mạnh đủ tốt (<strong>Clean Architecture</strong>) sẽ luôn đảm bảo tính <strong>scale</strong> và <strong>maintain</strong>. Giả sử ta cần làm thêm một tính năng mới hoặc cần thay cập nhật tính năng cũ đúng với nhu cầu người dùng. Nó ảnh hưởng tới toàn app nhưng vẫn đảm bảo lỗi phát sinh thấp nhất có thể và kịp thời gian release.</p><p>Một kiến trúc tệ là khi các (<strong>layer</strong>) bị ràng buộc(<strong>deeply couple</strong>) - phụ thuộc(<strong>dependency</strong>) chặt chẽ với nhau. Khi có bất cứ thay đổi — giả sử thêm hoặc sửa 1 model !! Oop !</p><h4>Tại sao một kiến trúc tốt lại có thể làm được điều đó ?</h4><p>Vì nó đủ tách biệt(<strong>decouple</strong>) giữa các tầng (layer) trong kiến trúc, mỗi tầng sẽ đảm nhiệm các nhiệm vụ riêng, để khi ta update thì sẽ ít bị ảnh hưởng nhất có thể. Tại sao nó lại như vậy? Đó là một phần nhờ vào <strong>SOLID </strong>và nhiều design pattern khác.</p><h4><strong>Tại sao lại là Clean hơn ?</strong></h4><ul><li>Tách biệt giữa các layer với các nhiệm vụ riêng của nó, làm cho nó dễ dàng sửa đổi.</li><li>Trừu tượng nhất có thể trên các class high level (<em>high và low-level trong nguyên lý DI</em>)</li><li>Khi apply <strong><em>Testing</em></strong> sẽ ít đau đớn hơn.</li></ul><blockquote><em>“Clean code always looks like it was written by someone who cares.”</em></blockquote><blockquote><em>— Michael Feathers</em></blockquote><h4><strong><em>Các Layers ?</em></strong></h4><p>Thường trong project sẽ có rất nhiều layer khác nhau, nhưng ta sẽ focus vào các layer chính:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*P8GK5QNhpoCXFWpCGQya6w.png" /><figcaption>Dependency Flow</figcaption></figure><p><strong>Domain Layer: </strong>Nó có thể thực hiện các logic về nghiệp vụ, nó độc lập với tất cả các layer khác. Trong Android nó sẽ chỉ là các class với Kotlin hoặc Java thuần túy, không có bất cứ class nào liên quan tới Android class ( như View, context, v.v.v). Thường sẽ bao gồm các packages :</p><ul><li><strong>Common, Entities</strong> : …. Utils, common, data entity classs.</li><li><strong>Reposittories</strong>: Là các <strong><em>interface</em></strong> tính năng mà usecase sử dụng, nó được implement tại data layer.</li><li><strong>Usecase </strong>: Thường chứa các class usecase là các class thực thi các logic của ứng dụng. Mỗi logic sẽ được chia ra thành các class riêng -Ex: LoginUsecase, NewsUsecase, ShipperUsecase.</li></ul><p><strong>Data Layer: </strong>Nó có thể cung cấp các data được yêu cầu cho toàn ứng dụng thông qua các interface được cung cấp bởi tầng domain. Data layer nên được thiết kế để có thể re-used tron ứng dụng và ít bị ảnh hưởng nhất có thể khi thay đổi logic. Thường sẽ bao gồm các packages :</p><ul><li><strong>API</strong>: Cung cấp remote network implement (Retrofit, Voley)</li><li><strong>DB</strong>: Local storage (Room, SQLite, Realm)</li><li><strong>Entites</strong>: Data entity class được sử dụng trong data layer</li><li><strong>Repository</strong>: <strong><em>Class implement</em></strong> cụ thể cho từng tính năng mà tầng Domain cần- Ex: getShipperInfo() get data từ DB local hay call API.</li></ul><p><strong>Presentation Layer: </strong>Layer quyết định sẽ hiển thị gì và nhận input gì từ giao diện người dùng. Tầng này sẽ thường sẽ được implement bởi các kiến trúc như MVP, MVVM, MVC, MVI, etc. Thườn sẽ bao gồm các package như :</p><ul><li><strong>DI</strong>:(Dependency Injection) Để tăng tính tách biệt(Decouple) giảm sự phụ thuộc giữa layer Presentation và các layer khác. Nhiệm vụ của DI là inject các usecase của tầng <strong>domain </strong>vào layer <strong>presentation.</strong></li><li><strong>Entities:</strong> Data class sẽ được hiển thị lên cho user và nhận các tương tác từ user.</li><li><strong>Mappers: </strong>Mapping Entity từ các layer khác tới layer Presentation và ngược lại.</li><li><strong>Presenter</strong> (ViewModel- Controller) ..etc Nhận và xử lý tất cả event tương tác từ user và control hiển thị nội dung cho View.</li><li><strong>Views</strong>: Các lớp chứa views. Là một views càng dumb(thụ động) càng make clear. Ex: show(), hide(), showToast(), showShipper(), onClick, etc.</li></ul><h3><strong>Flow của ứng dụng:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKpwa8G0_ZpZBVr0d0ONzA.png" /><figcaption>Overview Connection between layers</figcaption></figure><h3><strong>Tổng kết.</strong></h3><p>Sau bài viết này ta đã có những cái nhìn tổng quan về một kiến trúc tốt là như thế nào. Hi vọng nó sẽ giúp ích với mọi người. Nếu bài viết còn thiếu sót hay nội dung chưa phù hợp hãy response cho mình ở dưới dây. Rất mong các đóng góp của mọi người.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64bb3af29478" width="1" height="1" alt=""><hr><p><a href="https://medium.com/culi-tech-viet/clean-architecture-android-64bb3af29478">Clean Architecture Android</a> was originally published in <a href="https://medium.com/culi-tech-viet">Culi Tech Viet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pass data to the previous Fragment]]></title>
            <link>https://medium.com/culi-tech-viet/pass-data-to-the-previous-fragment-e2b1d19f39ca?source=rss-768f9aadc213------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2b1d19f39ca</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[fragments]]></category>
            <category><![CDATA[onactivityresult]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Luyen Ninh]]></dc:creator>
            <pubDate>Sat, 07 Mar 2020 07:15:23 GMT</pubDate>
            <atom:updated>2020-03-07T07:15:23.565Z</atom:updated>
            <content:encoded><![CDATA[<p>When we using fragment widely in the application to show data. Sure We have faced a question: “What is best practice to passing data to the previous fragment without EventBus, interface callback ?”. In the article, I will be showing a way to resolve that question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VnezNCyjBmlR1mbP" /><figcaption>Photo by <a href="https://unsplash.com/@euwars?utm_source=medium&amp;utm_medium=referral">Farzad Nazifi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Using onActivityResult</h4><p>When we start a fragment, I used a set target fragment and add fragment with a request code similar the way we start an activity for the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jv_k2S3wiM3hjTRJsPsHPw.png" /></figure><p>And pop back to the previous fragment with the result OK :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9GH2_KKAqplFNo0l8cElg.png" /><figcaption>Pop back result Ok</figcaption></figure><p>Or pop back with the result Cancel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0aQ7ERa3_0mLchgjq74DuQ.png" /><figcaption>Pop Back cancel the result</figcaption></figure><p>So now, we can receive data from call back result by the way override function onActivityResult on fragment:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r-tUv4BZbOCyILk8BtPqUg.png" /><figcaption>onActivity result on fragment</figcaption></figure><p>Above is a simple way we can resolve the question, but if we used to call back onActivityResult the flow business code can be a break and reduce readable.</p><p>With Kotlin, We can modify just a little bit some code to increase readable. On the Base class fragment, we need to add some code below to handle result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*llNuvMJAq-bB8qHPDXAwOQ.png" /><figcaption>Make extension function for Fragment</figcaption></figure><p>And using this function with a little code like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rGQDBN08Rw-y6whdyDKo4Q.png" /><figcaption>using with callback result for each request</figcaption></figure><p>And on Fragment A, we need popBack and push data to intent:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kv6SkCbMyvBIT1eWWAdxjQ.png" /></figure><h4>Conclusion</h4><p>Using combine extension function and function receiver we can make a DSL code short than, readable. I think it will be helpful in your project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2b1d19f39ca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/culi-tech-viet/pass-data-to-the-previous-fragment-e2b1d19f39ca">Pass data to the previous Fragment</a> was originally published in <a href="https://medium.com/culi-tech-viet">Culi Tech Viet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Start CI-CD for mobile with Jenkins and Fastlane]]></title>
            <link>https://medium.com/culi-tech-viet/start-ci-cd-for-mobile-with-jenkins-and-fastlane-7c44a8c66dde?source=rss-768f9aadc213------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c44a8c66dde</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[fastlane]]></category>
            <dc:creator><![CDATA[Luyen Ninh]]></dc:creator>
            <pubDate>Sat, 23 Nov 2019 09:48:55 GMT</pubDate>
            <atom:updated>2020-02-06T07:17:56.437Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Sometimes, I have questions about CI and CD my project android, how to </em><strong><em>build my project android on the server</em></strong><em> and auto </em><strong><em>distribute</em></strong><em> apk to Play Store only with a git push command?</em></p><blockquote>I’m android developer and I don’t have any knowledge about DevOp. When I research about CICD, I was face off with many new keywords like ‘centOS’, ‘root’, ‘permissions’ and etc. But In the article I will show my approach with Jenkins and CICD. I hope it will be helpful with readers.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*JpYHpG35zDeh2Bsji3QxDw.jpeg" /></figure><blockquote>Environment : I’m using Centos OS 7 to setup jenkins.</blockquote><h3>Install Jenkins</h3><p>Because Jenkins is run on JVM, we need to install JDK and JRM</p><pre>$ sudo yum install java-1.8.0-openjdk-devel</pre><p>The current version of Jenkins does not support Java 10 (and Java 11) yet. If you have multiple versions of Java installed on your machine <a href="https://linuxize.com/post/install-java-on-centos-7/#set-the-default-version">make sure Java 8 is the default Java version</a>.</p><p>The next step is to enable the Jenkins repository. To do that, import the GPG key using the following <a href="https://linuxize.com/post/curl-command-examples/">curl</a> command:</p><pre>$ curl --silent --location <a href="http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo">http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo</a> | sudo tee /etc/yum.repos.d/jenkins.repo</pre><p>And add the repository to your system with:</p><pre>$ sudo rpm --import <a href="https://jenkins-ci.org/redhat/jenkins-ci.org.key">https://jenkins-ci.org/redhat/jenkins-ci.org.key</a></pre><p>Now start to install <strong>Jenkins</strong></p><pre>$ sudo yum install jenkins</pre><p>After the installation process is completed, start the Jenkins service with:</p><pre>$ sudo systemctl start jenkins</pre><p>To check Jenkins started :</p><pre>$ systemctl status jenkins</pre><pre>--output--<br>● jenkins.service - LSB: Jenkins Automation Server<br>Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)<br>Active: active (running) since Thu 2018-09-20 14:58:21 UTC; 15s ago<br>    Docs: man:systemd-sysv-generator(8)<br>Process: 2367 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)<br>CGroup: /system.slice/jenkins.service</pre><p>Finally, we can set up Jenkins start-up when rebooting</p><pre>sudo systemctl enable jenkins</pre><p>If you are installing Jenkins on a remote CentOS server that is <a href="https://linuxize.com/post/how-to-setup-a-firewall-with-firewalld-on-centos-7/">protected by a firewall</a> you need to port 8080.</p><p>Use the following commands to open the necessary port:</p><pre>$ sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp<br>sudo firewall-cmd --reload</pre><h4>Test Jenkins</h4><p>Now we can test Jenkins from my client pc, open your browser and open url</p><pre><a href="http://your_ip_or_domain:8080/">http://your_ip_or_domain:8080</a></pre><p>After that, we can create an account to login the Jenkins system.</p><figure><img alt="we have a bridge, let’s run !" src="https://cdn-images-1.medium.com/max/1024/0*IqcuJm2aZf8o6Enf" /><figcaption>Photo by <a href="https://unsplash.com/@intothefab?utm_source=medium&amp;utm_medium=referral">Fabio Comparelli</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Create Jobs install Fastlane</h3><blockquote><strong><em>To avoid the article too long to read, I was just create jobs with “execute shell ”, not using another integrate like github, etc</em></strong></blockquote><p>On the left side menu of the Jenkins home page click to</p><pre>New Item -&gt; Enter an item name of jobs &quot;Install fastlane&quot; and select -&gt; Freestyle project -&gt; ok</pre><p>Input your “Description” of jobs and Scroll to “Build” section, click to “Add build step”, select “Execute shell” and parse below command to form:</p><pre>$ sudo gem install fastlane -NV</pre><p>Click to “Save” and ”Apply”.</p><p>On the screen Job detail, click to “Build Now” on the left side menu to run this job. On the section Build History, click to the lasted build time, and click to “Console Output” to see the detail output of the command.</p><pre>Finished: SUCCESS</pre><p>This really nice, but Some time we can face off with errors, I will list in below</p><p><strong>Install Fastlane Error :</strong></p><p>To quickly execute the command lines set up something we should be using ssh and using the terminal, to login with Jenkins user we need login and create a password, to switch Jenkins user:</p><pre>su - jenkins -s /usr/bin/sh</pre><p>Ruby does not install before, Because we have using “gem” to install Fastlane</p><blockquote><strong>RubyGems</strong> is a <a href="https://en.wikipedia.org/wiki/Package_manager">package manager</a> for the <a href="https://en.wikipedia.org/wiki/Ruby_programming_language">Ruby programming language</a> that provides a standard format for distributing Ruby programs and <a href="https://en.wikipedia.org/wiki/Library_(computing)">libraries</a> (in a self-contained format called a “gem”)</blockquote><pre>$ sudo yum install ruby<br>$ gem install rubygems-update</pre><p><em>//Response your error to</em></p><h3><strong>Create Job Build project Android</strong></h3><h4><strong>Download Android-SDK</strong></h4><p>The first step we need to install android SDK and setup Android SDK variable environment,</p><pre>$ wget --output-document=android-sdk.zip --quiet <a href="https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip">https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip</a></pre><pre>$ unzip android-sdk.zip</pre><p>To get lasted Android SDK version we can download <a href="https://developer.android.com/studio#downloads">here</a>. And export Android SDK variable</p><pre>$ export ANDROID_SDK_ROOT=/home/download/</pre><p>/home/download is my folder exist android SDK,</p><h4><strong>Create Job clone source from git</strong></h4><p>The step by step to create a job like we have created a job to download Fastlane above. We just need to change the command install Fastlane to the command clone git below:</p><pre>$ git clone `URL_YOU_REPO`</pre><h4><strong>Create Job build android project with test</strong></h4><p>Create a job on Jenkins home page to execute shell below:</p><pre>$ cd YOUR_PROJECT_FOLDER<br>$ /usr/local/bin/fastlane init<br>$ /usr/local/bin/fastlane android test</pre><p>That’s it! <em>fastlane</em> will automatically generate a configuration for you based on the information provided.</p><h3><strong>Conclusion</strong></h3><p>Congratulation! You have to imagine about Jenkins, step by step create jobs with Jenkins and a little experience to resolve stuck with Jenkin and Fastlane. Ready to face off with new challenges using another feature of Jenkins, for example: how to autorun test job when you submit a merge request?</p><p><strong><em>Read more at :</em></strong></p><p><a href="https://medium.com/culi-tech-viet">Culi Tech Viet</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c44a8c66dde" width="1" height="1" alt=""><hr><p><a href="https://medium.com/culi-tech-viet/start-ci-cd-for-mobile-with-jenkins-and-fastlane-7c44a8c66dde">Start CI-CD for mobile with Jenkins and Fastlane</a> was originally published in <a href="https://medium.com/culi-tech-viet">Culi Tech Viet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What are differences of cluster and nonclustered index in database ?]]></title>
            <link>https://medium.com/@luyenninh/what-are-differences-of-cluster-and-nonclustered-index-in-database-e2e2b5a963c1?source=rss-768f9aadc213------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2e2b5a963c1</guid>
            <dc:creator><![CDATA[Luyen Ninh]]></dc:creator>
            <pubDate>Sat, 23 Nov 2019 05:07:52 GMT</pubDate>
            <atom:updated>2019-11-23T05:07:52.928Z</atom:updated>
            <content:encoded><![CDATA[<h3>What are differences of cluster and nonclustered index in database ?</h3><p>Let’s take your the coffee cup and relax to know about the differences of the cluster and nonclustered index.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2e2b5a963c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Roadmap Question and Answer]]></title>
            <link>https://medium.com/culi-tech-viet/android-roadmap-question-and-answer-fcdae2029564?source=rss-768f9aadc213------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcdae2029564</guid>
            <dc:creator><![CDATA[Luyen Ninh]]></dc:creator>
            <pubDate>Thu, 14 Nov 2019 10:35:25 GMT</pubDate>
            <atom:updated>2019-12-02T09:19:44.613Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android Roadmap Question and Answers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SHx016LYT93wSFcUf40C4Q.png" /></figure><h3>Programming languages</h3><h4><strong>1. Compare Java and Kotlin (Pros and Cons) ?</strong></h4><ul><li><strong><em>What is Java ?</em></strong></li></ul><p>// write here</p><ul><li><strong><em>Pros of Java ?</em></strong></li></ul><p>//write here</p><ul><li><strong><em>Cons of Java ?</em></strong></li></ul><p>//Write here</p><p><strong><em>What is Kotlin ?</em></strong></p><p>// write here</p><ul><li><strong><em>Pros of Kotlin ?</em></strong></li></ul><p>//write here</p><ul><li><strong><em>Cons of Kotlin ?</em></strong></li></ul><p>//Write here</p><h3>Android Studio</h3><p><strong>1. File và cấu trúc thư mục(mục đích - các loại file trong folder): Cấu trúc folder resources ?</strong></p><p>Folder:</p><ul><li>Manifest: chứa file manifest</li><li>App: java: chứa code java ///more @</li><li>res: chứa resources</li><li>Gradle: chứa file gradle</li></ul><p>File:</p><ul><li>Android manifest: file đăng ký application, activity, permission,…</li><li>Res: drawable: image not resize, mipmap: image resize due to screen resolution, layout: contains file layout for view class, values: contains value color, string, dimen, style use for app.</li><li>Gradle: file register library</li><li>Setting.gradle: project setting</li><li>Proguard-rules.pro: rules for encrypt</li></ul><p><strong>2. Một số hotkey thường dùng trong Android Studio ?</strong></p><ul><li>CTRL-Z, CTRL-SHIFT-Z: undo</li><li>CTRL-X, CTRL-L: cut</li><li>CTRL-ALT-L: Auto format code</li><li>CTRL-Q: view introduce of function, parameter,..</li><li>CTRL-F4: Close tab present</li><li>CTRL-S: Save</li><li>ALT-F7: Find usages</li><li>F4: Find initialize</li><li>Shift-F6: Refactor, rename</li><li>(F11 —Agree kick — Deprecated)</li></ul><h4>3. Tips Debug ?</h4><p>Cách đọc và sử dụng filter log :</p><ul><li>Đọc lỗi đầu tiên throw ra, có đường dẫn chỗ lỗi (tên class + số dòng) thì bấm vô coi.</li><li>Đặt breakpoint function nghi là lỗi để xem nó có những param nào</li><li>Đặt log.d(TAG,…) để dễ theo dõi log</li></ul><p>//@todo : sử dụng filter và regex để filter nhanh được thông tin cần sử dụng.</p><h3>Android Manifest</h3><ol><li><strong><em>Cấu trúc file manifest ?</em></strong></li></ol><p>Cần dùng để đăng ký package name, application ID, các component như activity services receiver, permission và device compability</p><p><strong>2. Implement backup — data ?</strong></p><p><strong>3. Permission ?</strong></p><p><strong>Why the application need define permission ?</strong></p><blockquote>Every Android app runs in a limited-access sandbox. If an app needs to use resources or information outside of its own sandbox, the app has to request the appropriate <em>permission.</em> You declare that your app needs a permission by listing the permission in the <a href="https://developer.android.com/guide/topics/manifest/manifest-intro.html">app manifest</a> and then requesting that the user approve each permission at runtime (on Android 6.0 and higher).</blockquote><p><strong>How many protection level of the permission in android system ?</strong></p><ul><li>Normal Permission :</li></ul><p>//Todo: write here</p><ul><li>Signature Permission :</li></ul><p>//Todo: write here</p><ul><li>Dangeros Permission:</li></ul><p>//Todo: write here</p><h4>What is Deeplink ? implement như nào trong manifest</h4><p>Thêm intent filter và action trong component đăng ký activity</p><blockquote><a href="https://medium.com/u/c72f9c7ad7b6">Xuân Lộc Lê</a> cụ thể, thêm example code</blockquote><h4>Intent filter là gì ?</h4><p>Là phễu lọc intent, khi gặp trường hợp gọi nào match thì lấy intent có thể nhất ra trong list intent.</p><h4>Sự khác biệt của Intent Implicit và Intent Explicit ?</h4><p>Explicit intent, dịch thẳng ra nghĩa đen là “ý định rõ ràng”, nghe quá chuối nên dịch là “intent rõ ràng” cho đỡ chuối. Explicit intent được dùng khi ta biết rõ component nào để đến trực tiếp, cũng như không muốn người dùng có lựa chọn khác tốt hơn. Ex: Có 2 activity A và B, ta muốn đến activity B từ activity A thì khai báo 1 explicit intent.</p><p>Implicit intent, không chỉ định rõ ràng component đặc biệt nào sẽ được chuyển đến trực tiếp, nó chỉ chỉ định hành động nào sẽ được thực hiện. Nếu chỉ tìm được 1 component thì android sẽ mở ngay component đó. Nếu không thì sẽ hiện ra list component để chọn.</p><p>Vd: Intent mở 1 trang web bằng URI thông qua ACTION_VIEW, lúc này android tìm thấy vài browser và show list lên.</p><h3>App Component</h3><h4>Activity Life Cycle</h4><p>-Luồng chính: onCreate, onStart, onResume, onPause, onStop, onDestroy.<br>-Khi đang dùng app mà có thông báo =&gt; onPause, không xem thông báo =&gt; onResume, navigate tới app khác =&gt; onStop<br>-Đang ở app khác mở lại app mình =&gt; onRestart &amp; onStart<br>-Mở trình task control rồi end process =&gt; onDestroy</p><p><strong>savedInstanceState</strong>: dùng để lưu trạng thái để restore vào các view sau khi destroy. Ví dụ khi xoay ngang màn hình, các giá trị của các view tạo trong onCreate,… sẽ bị mất (do android thực hiện onDestroy và quay lại onCreate).<br>Ta có thể dùng Bundle để lưu các giá trị và restore trong onCreate hoặc override hàm onRestoreInstanceState.</p><h4>Fragment</h4><p><a href="https://medium.com/culi-tech-viet/fragment-android-9aaf67e55a22">https://medium.com/culi-tech-viet/fragment-android-9aaf67e55a22</a></p><h4><strong>Broad Cast Receiver</strong></h4><p>Là chức năng lắng nghe các sự kiện, trạng thái của hệ thống phát ra thông qua Intent. Broadcast có thể chạy nền (chung với service).</p><p>Changes log broadcast receiver</p><p>- Ở android 9 (api 28), the NETWORK_STATE_CHANGED_ACTION không nhận thông tin về vị trí của người dùng hoặc dữ liệu nhận dạng cá nhân.</p><p>- Ở android 8 (api 26), không thể register broadcast trong manifest. Chỉ được register trong context.</p><p>- Ở android 7 (api 24), phải đăng ký chương trình phát sóng CONNECTIVITY_ACTION bằng cách sử dụng registerReceiver, không thể register broadcast trong manifest. Chỉ được register trong context.</p><h3>Tasks — Back Stack</h3><h4>Task là gì ?</h4><p>Task là tập hợp những acitivty mà người dùng tương tác. Các activity này được sắp xếp trong stack — gọi là back stack — theo thứ tự mở trước sau. Nghĩa là khi người dùng nhấn back button thì activity hiện tại trong backstack sẽ pop và activity trước đó sẽ được reactive.<br>Trường hợp app được chạy trong multi thread (hỗ trợ android 7.0 trở lên), hệ thống android sẽ chia ra 2 trình quản lý stack khác nhau, mỗi màn hình sẽ có 1 trình quản lý task</p><h4>Cơ chế Stack ?</h4><p>Cơ chế: “last in, first out”, stack không thể sắp xếp, chỉ có thể push hoặc pop.,</p><figure><img alt="A task adds an item to the back stack. When the user presses the Back button" src="https://cdn-images-1.medium.com/max/617/0*UoXylMppKdX0CMdS.png" /></figure><h4>Khi nào Task bị kill ?</h4><p>Nếu người dùng rời khỏi task trong một thời gian dài, hệ thống sẽ dọn dẹp các activity trong task ngoại trừ root activity. Khi người dùng quay trở lại task, chỉ có root activity được khôi phục</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcdae2029564" width="1" height="1" alt=""><hr><p><a href="https://medium.com/culi-tech-viet/android-roadmap-question-and-answer-fcdae2029564">Android Roadmap Question and Answer</a> was originally published in <a href="https://medium.com/culi-tech-viet">Culi Tech Viet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Save environment]]></title>
            <link>https://medium.com/series/save-environment-8c3caafcab0?source=rss-768f9aadc213------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c3caafcab0</guid>
            <dc:creator><![CDATA[Luyen Ninh]]></dc:creator>
            <pubDate>Sun, 20 Oct 2019 04:35:22 GMT</pubDate>
            <atom:updated>2019-10-20T04:35:22.641Z</atom:updated>
            <content:encoded><![CDATA[<h3>Save the environment to save Life</h3><p>Bad day</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c3caafcab0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stack And Heap in Java]]></title>
            <link>https://medium.com/culi-tech-viet/stack-and-heap-in-java-b25163f1d14b?source=rss-768f9aadc213------2</link>
            <guid isPermaLink="false">https://medium.com/p/b25163f1d14b</guid>
            <category><![CDATA[memory-leak]]></category>
            <category><![CDATA[heap]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[stack]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Luyen Ninh]]></dc:creator>
            <pubDate>Sat, 03 Aug 2019 04:35:19 GMT</pubDate>
            <atom:updated>2019-08-03T04:35:19.413Z</atom:updated>
            <content:encoded><![CDATA[<p>In the article I’ll clarify the difference Stack and Heap in Java. How do it work in memory. I think it really important for all Java professional to understand. When you know how do it work, we can avoid write some code which could crash application with memory error. Okay ! Please take your coffee cup away.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_R_gqltLNIiM0Sgj" /><figcaption>Photo by <a href="https://unsplash.com/@luisviol?utm_source=medium&amp;utm_medium=referral">Luis Villasmil</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>1. What is stack and heap in memory ?</strong></h3><p>When our application running, they need access to some of our device’s memory(RAM). For example when we create a variable, object and hold it on the memory. This memory split to two sections the stack and the heap.</p><h3><strong>2. The Stack how do it work ?</strong></h3><p>The stack used widely, But there isn’t a single stack. Which created for each thread. Whenever we create a new thread, the JVM(Java visual machine) will be allocated a stack for this on the memory. In other words, every thread has its own stack. The process allocated stack on memory is dealt with when the program is compile.</p><p><em>//image multi thread and multi stack</em></p><p>Mechanism put data on stack is FILO(First In Last Out) data structure. We add data to the stack by pushing it to the top. And the new item goes on to the top. When the stack want to be freed, the item on top(that is the last item to be added) always is first item removed.</p><p>But when is stack want to be freed ?<br>In the function when compiler run to statement “return xxx” then all variable have declared before will be remove from the stack. And If the method without return then all variable have declared before will be remove from the stack when compiler run to the last curly brackets of method. In another words, when thread is completed then our stack would now be empty.</p><p><em>// animation add and remove items in stack.</em></p><h3><strong>3. The Heap how do it work ?</strong></h3><p>The Heap allows us to store data that has long lifetime than a single code block or function. For example object which is shared across multiple methods. You can think of the heap as being a huge area for storing data. Actually, you can think of the heap as being all the memory of your application except for the data on the stacks.</p><p>In an application there is one heap which is shared across all the threads</p><p>In Java, all objects are stored on the heap. So the stack is used for local primitive variables such as int, double, long but all objects such as String, Customer, or Integer Object will be stored on the heap. For the objects on the heap there’ll be a pointer to the object which is the variable reference stored on the stack.</p><p>For example :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*e1VpslnCG8bO8MXa-1oqsA.png" /></figure><p>In the stack , variable “name” is the variable that contains the memory address reference to where in the heap this object lives.</p><ul><li>The Objects are stored on the heap.</li><li>Variable are a reference to the object</li><li>As a local variable will be stored on the stack.</li></ul><p><em>Above this is simple example when we declare variable in java. What happen when we pass data through argument, declare and modify data in collections (List, HashMap ) in java ?</em></p><h3><strong>4. Value, references and escaping references.</strong></h3><ul><li><strong><em>With primitive data ?</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*WKZ-ZhJBkEe0LfKhLo00Ww.png" /></figure><p>The all variable above will be storage on the stack(the right rectangle). At the first line in the main method. The variable <em>localValue </em>will be storage on the stack. When the compiler run to calculate method, in the argument we create a variable is <em>calcValue </em>and assign data of <em>localValue </em>to it and storage it on the stack. When the compiler run into the first line in the <em>calculate </em>method. we increase and assign new data for <em>calcValue.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*NN3uUsc9q1Ls2iK-CMtVNg.png" /></figure><p>At the last. When compiler print data of <em>localValue </em>to screen, then value of <em>localValue </em>always equal five.</p><p>→ So, passing variables into methods in Java is always done by making a copy of the variable.</p><p><em>In another language like c++ we can pass the variables by reference.</em></p><pre>#include &lt;stdio.h&gt;</pre><pre>//using &amp; keyword to create variable reference.<br>void swapnum(int &amp;i, int &amp;j) {<br>  int temp = i;<br>  i = j;<br>  j = temp;<br>}<br><br>int main(void) {<br>  int a = 10;<br>  int b = 20;<br><br>  swapnum(a, b);</pre><pre>  printf(&quot;A is %d and B is %d\n&quot;, a, b);</pre><pre>  return 0;<br>}</pre><p><em>And out put : </em>A is 20 and B is 10</p><ul><li><strong><em>With Object data ?</em></strong></li></ul><p>What happen in java when we passed a Object through argument.</p><p>→ For objects passed into methods, the <strong>Reference</strong> to the object is passed <strong>By value</strong>. It mean copy a pointer to the object is created, the object itself is not copied.</p><p>Example :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*ZA6ZkrT03374s5Oe0tfi4Q.png" /><figcaption>running to the first line</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*R0WWp4DvFktn4EXKOHYMPA.png" /><figcaption>2. Call renameCustomer()</figcaption></figure><p>The variables <em>c</em> and <em>cust </em>on the <strong>Stack </strong>both reference to the Customer object on the <strong>Heap</strong>. And the name of customer had new reference to value is Diane. The data String with value Sally is not reference. It will be remove by <strong>GC </strong>( Garbage Collection).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*oSwCcCdfhg_Ew3L1yriQDQ.png" /></figure><ul><li><strong>Avoid escaping references with custom Object.</strong></li></ul><p>If we have a list Customer. we just want to create and can not modify data on original Customer Object.</p><ul><li><strong><em>We using the collection ?</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*yk7Znu3M0b_2_-k6U59ijg.png" /></figure><p>When we using method getCustomers(), this return a pointer directly to the Map <em>records and i</em>t can do anything likes with that collection<em>. </em>The reference to the map has escaped from the class in which it should have been encapsulated. It’s almost as though we have declare this map as a public variable<strong><em>.</em></strong></p><p><strong><em>→ So we have violated the encapsulation rules.</em></strong></p><p>And the real pain of this kind of circumstance is that we now have a very difficult job in debugging.<br>Solution to avoid return a pointer reference to the Map <em>record. </em>We can return a new HashMap&lt;String,Customer&gt;(record), it mean we will create a copy HashMap to do something.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*w_8kObrVkHdE_SqW94kFcg.png" /></figure><p>We can see the difference</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*3FPKAYCSayShdLQExmUbQw.png" /></figure><p>With case we new ArrayList(collection1) we have create a new Object List on the heap, but we have hold a reference with Customer A and Customer B in collection1.</p><p><em>But we still change data and impact to the original collection</em>. Example : We can rename of CustomerB to CustomerX on collection3, CusomterB on the collection1 will be change to CustomerX at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*LMCPO5XouwMgOPTvfqfkzQ.png" /><figcaption>change CustomerB to CustomerX</figcaption></figure><p>To resolve problem. We want create a immutable HashMap. In java we can do it with Collection. We can using the Collections.unmodifiableMap()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*Pcbqd6bV9WiRM4HB5yvdMQ.png" /><figcaption>Using Collections.unmodifiableMap</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b25163f1d14b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/culi-tech-viet/stack-and-heap-in-java-b25163f1d14b">Stack And Heap in Java</a> was originally published in <a href="https://medium.com/culi-tech-viet">Culi Tech Viet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wallpapers App : Wallpapers HD,2k, 4k background.]]></title>
            <link>https://medium.com/@luyenninh/wallpapers-app-wallpapers-hd-2k-4k-background-5608f587567?source=rss-768f9aadc213------2</link>
            <guid isPermaLink="false">https://medium.com/p/5608f587567</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[wallpaper]]></category>
            <category><![CDATA[beautifull-wallpaper]]></category>
            <category><![CDATA[2k-background]]></category>
            <category><![CDATA[app-wallpaper]]></category>
            <dc:creator><![CDATA[Luyen Ninh]]></dc:creator>
            <pubDate>Tue, 17 Jul 2018 05:01:48 GMT</pubDate>
            <atom:updated>2018-07-17T05:01:48.345Z</atom:updated>
            <content:encoded><![CDATA[<p>Wallpaper App : Wallpapers HD,2k, 4k background.</p><p>The first thing ! I’m finding a application help me auto change my wallpapers follow my hobbies. I have looking for many application on play store ,but each app exist some disadvantage. The last I decided I should create new application made myself to approve my condition. And I hope it will suitable with another users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LsgH9dmZfHKGMeSo" /><figcaption>“A woman with her arms spread out on top of a mountain.” by <a href="https://unsplash.com/@a_wandering_yogi?utm_source=medium&amp;utm_medium=referral">Kristina Wagner</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>Find resources</strong></h3><p>I have searching on the google about website free image resource highest quality for use set wallpapers. I was found some resource but it very expensive( cost high) because I’m not a rich. I was continue searching. And in the beautiful day. I was find out a website free and suitable for this. It is unsplash.com. I have reading about license of Unsplash. It content is: all photos published on Unsplash can be used for free. You can use them for commercial and noncommercial purposes. It awesome !</p><h3><strong>Listed Features</strong></h3><p>I want to create a application base on feature set wallpaper. But additional some features helpful for user, for examples:</p><ul><li>Search wallpapers. User can search everything like 😃 : girls, boy, computers, anything else.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CrrAJVOMnb2wrtwpKBjwhw.png" /></figure><ul><li>Show category of wallpapers. Each user will have favorite a different kind of photos, for examples: natural, love, house, animal, landscape.</li><li>Sort order by popular or high rating wallpapers.</li><li>Favorite photos and save recent photos it helpful for user when user want to search it again.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*lHeAilSPJxk3AvdNI4ebTQ.jpeg" /><figcaption>My wallpapers screen</figcaption></figure><ul><li>Show photos of user on the app. User can chose a picture from local storage device to set wallpaper.</li><li>Auto change wallpapers with interval define before. User can set auto change wallpapers from list favorite photos, list recent photos, or from storage of device.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*EWDHgcZ7p-iRJaZU3tBW9A.jpeg" /></figure><ul><li>View Photo and see any more. When user choose a picture, application will show detail of photo, it very details : about Photographer name (because almost photos in Unsplash taken by photographers), about location of photo, specs(camera model, aperture, iso, local length, resolution, exposure). And the last important information is related photos. User can see photo in full screen, zoom in , zoom out photo. With advantage photo high quality it helpful for user can zoom in and set it to wallpaper.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*4Y2In2m9SkaAcqPl-TWz3w.jpeg" /></figure><ul><li>Download and set wallpaper. User have three options: quick set (with single click user have set it to wallpaper successful), set as(it will show options of OS, user can set that photo to lock screen, contact, home and lock screen or another option depend os of device) and download it will save photo to gallery of device.</li><li>Share and open photo in another app. I’m using deep link to help for user open photo from link of Unsplash from browser on another app.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*gwhZTCeh1CMVZ_A2u62MSg.jpeg" /><figcaption>open app from messenger browser</figcaption></figure><h3><strong>Develop and Production:</strong></h3><p>Please click to link below and download app. If you have any question and comment, please complain and rating on the Play store site or comment on below article.</p><p><a href="https://play.google.com/store/apps/details?id=ninh.luyen.wallpapers">WallPapers HD, 2k, 4k background - Apps on Google Play</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5608f587567" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>