<?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 Ali Göktaş on Medium]]></title>
        <description><![CDATA[Stories by Ali Göktaş on Medium]]></description>
        <link>https://medium.com/@aligoktass?source=rss-5c4d88745196------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MErztCKLWJyvY_1Q6jIpAg@2x.jpeg</url>
            <title>Stories by Ali Göktaş on Medium</title>
            <link>https://medium.com/@aligoktass?source=rss-5c4d88745196------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:04:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aligoktass/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[Git and GitFlow: A Beginner’s Guide with Examples]]></title>
            <link>https://aligoktass.medium.com/git-and-gitflow-a-beginners-guide-with-examples-57bccede50d7?source=rss-5c4d88745196------2</link>
            <guid isPermaLink="false">https://medium.com/p/57bccede50d7</guid>
            <category><![CDATA[bitbucket]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[gitflow]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Ali Göktaş]]></dc:creator>
            <pubDate>Tue, 14 Mar 2023 08:21:00 GMT</pubDate>
            <atom:updated>2023-03-14T08:21:00.830Z</atom:updated>
            <content:encoded><![CDATA[<p>Git is a popular version control system that allows developers to track changes in their code and collaborate with others on a project. GitFlow is a branching model for Git that provides a clear and consistent approach to managing code changes and releases. In this article, we’ll provide a beginner’s guide to Git and GitFlow, including examples of how they can be used in real-world scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CEyiDu_mQ5u9NI0Fr2pSdA.png" /></figure><h3>Git Basics</h3><p>Git uses a decentralized approach to version control, which means that each developer has their own copy of the code repository on their local machine. This allows developers to work on their own branch without affecting the main codebase until they are ready to merge their changes back into the repository. Here are some basic Git commands to get started:</p><ul><li>git init: Create a new Git repository</li><li>git clone: Copy an existing Git repository to your local machine</li><li>git add: Add changes to the staging area</li><li>git commit: Save changes to the repository</li><li>git push: Upload changes to a remote repository</li><li>git pull: Download changes from a remote repository</li><li>git merge: Combine changes from different branches</li><li>git branch: Create, list, or delete branches</li></ul><h3>GitFlow Overview</h3><p>GitFlow is a branching model for Git that provides a clear and consistent approach to managing code changes and releases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q8MmK6j-P8Wb6T2zz0crJw.png" /></figure><p>The GitFlow model consists of two main branches:</p><ul><li>master: The main branch that represents the stable production code.</li><li>develop: The branch used for ongoing development work.</li></ul><p>In addition to these main branches, GitFlow also uses the following types of branches:</p><ul><li>feature: Branches used for developing new features.</li><li>release: Branches used for preparing a new release.</li><li>hotfix: Branches used for fixing critical issues in production code.</li></ul><h3>GitFlow Example Usages</h3><p>Let’s take a look at some examples of how GitFlow can be used in real-world scenarios.</p><h4><strong>Example 1: Managing Feature Development</strong></h4><p>Let’s say you’re working on a web application, and your team needs to add a new feature that allows users to create and save custom playlists. Here’s how GitFlow can help you manage the development process:</p><ol><li><strong>Create a new feature branch</strong>: Use the git flow feature start command to create a new branch from the develop branch for the playlist feature.</li></ol><pre>git flow feature start playlist</pre><p>2. <strong>Develop the feature</strong>: Start working on the playlist feature on the new branch.</p><pre>git checkout playlist</pre><p>3. <strong>Commit changes</strong>: As you work on the feature, commit your changes regularly to the feature branch.</p><pre>git add .<br>git commit -m &quot;Added playlist creation functionality&quot;</pre><p>4. <strong>Test and review</strong>: Once the feature is complete, test it thoroughly and have it reviewed by other team members.</p><p>5. <strong>Merge the feature</strong>: When the feature is ready to be merged back into the develop branch, use the git flow feature finish command.</p><pre>git flow feature finish playlist</pre><p>6. <strong>Deploy</strong>: Once the develop branch is stable and ready for release, merge it into the master branch and deploy the new code to the production environment.</p><pre>git flow release start 1.0.0<br>git flow release finish 1.0.0</pre><h3>Hotfixes:</h3><p>Sometimes bugs or issues can arise in production code that need to be fixed quickly. GitFlow can help you manage hotfixes efficiently and safely.</p><ol><li><strong>Create a new hotfix branch</strong>: Use the git flow hotfix start command to create a new branch from the master branch for the hotfix.</li></ol><pre>git flow hotfix start bugfix-1</pre><p>2. <strong>Fix the issue</strong>: On the hotfix branch, make the necessary changes to fix the issue.</p><pre>git checkout bugfix-1</pre><p>3. <strong>Commit changes</strong>: As you fix the issue, commit your changes regularly to the hotfix branch.</p><pre>git add .<br>git commit -m &quot;Fixed bug causing application crash&quot;</pre><p>4. <strong>Test and review</strong>: Once the hotfix is complete, test it thoroughly and have it reviewed by other team members.</p><p>5. <strong>Merge the hotfix</strong>: When the hotfix is ready to be merged back into the master branch, use the git flow hotfix finish command.</p><pre>git flow hotfix finish bugfix-1</pre><p>6. <strong>Deploy</strong>: Once the master branch is updated with the hotfix, deploy the new code to the production environment.</p><p>Git and GitFlow are powerful tools for managing code changes and releases in a collaborative development environment. By following the GitFlow model, you can ensure that your team has a clear and consistent approach to managing code changes, which can help prevent conflicts and make releases more efficient. Whether you’re a beginner or an experienced developer, Git and GitFlow are essential tools to have in your toolkit.</p><p>In conclusion, Git and GitFlow are powerful tools for managing code changes and releases in a collaborative development environment. With GitFlow, you can follow a consistent and efficient approach to managing feature development, hotfixes, and releases. By mastering the basics of Git and GitFlow, you can become a more efficient and effective developer, and contribute to your team’s success.</p><p>Thank you for your time and please feel free to directly reach me in case of having any question or suggestion. 😇 😇</p><p><a href="https://www.linkedin.com/in/aligkts/">https://www.linkedin.com/in/aligkts/</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FVT3zPktC9eO52kuuw4%2Fvideo&amp;display_name=GIPHY&amp;url=https%3A%2F%2Fgiphy.com%2Fclips%2Fanidom-fox-family-guy-the-lois-quagmire-VT3zPktC9eO52kuuw4&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2FVT3zPktC9eO52kuuw4%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="480" height="270" frameborder="0" scrolling="no"><a href="https://medium.com/media/6277eeaf2169c712cdae4c3a087d4932/href">https://medium.com/media/6277eeaf2169c712cdae4c3a087d4932/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57bccede50d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Work Manager]]></title>
            <link>https://aligoktass.medium.com/android-work-manager-674606ce6437?source=rss-5c4d88745196------2</link>
            <guid isPermaLink="false">https://medium.com/p/674606ce6437</guid>
            <category><![CDATA[workmanager]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-workmanager]]></category>
            <category><![CDATA[jetpack-component]]></category>
            <dc:creator><![CDATA[Ali Göktaş]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 07:30:41 GMT</pubDate>
            <atom:updated>2023-01-20T07:36:47.380Z</atom:updated>
            <content:encoded><![CDATA[<p>Background tasks are an essential part of any Android app, allowing developers to perform actions such as sending data to a server or cleaning up local storage without interrupting the user experience. However, scheduling these tasks can be a tricky task, as developers must balance the need to perform the task with the need to conserve battery power.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*tRL4LQsqR-hCYVfR2dnw9w.png" /></figure><p>Enter Android Work Manager, a library that makes it easy to schedule and execute background tasks in a way that is optimized for power consumption. In this article, we’ll take a look at how to implement both OneTime and Periodic Work Manager tasks, and how to customize it to fit the needs of your app, using Kotlin as the programming language.</p><p>First, let’s start by adding the Work Manager dependency to our app’s build.gradle file:</p><pre>implementation &quot;androidx.work:work-runtime:2.4.0&quot;</pre><p>Next, we’ll create a new class that extends the Worker class. This class will contain the code for our background task. For example, here&#39;s a simple worker that sends a message to a server:</p><pre>import androidx.work.Worker<br><br>class SendMessageWorker(<br>  context: Context, <br>  params: WorkerParameters<br>) : Worker(context, params) {<br><br>    override fun doWork(): Result {<br>        // Code to send message to server<br>        return Result.success()<br>    }<br>}</pre><p>Now that we have our worker class, we can schedule it using the Work Manager.</p><p>First we will look into scheduling a one time task:</p><pre>import androidx.work.OneTimeWorkRequest<br><br>val sendMessageWork = OneTimeWorkRequestBuilder&lt;SendMessageWorker&gt;().build()<br>WorkManager.getInstance(this).enqueue(sendMessageWork)</pre><p>This is a basic example of how to use Android Work Manager to schedule a one time background task.</p><p>Next, we will look into scheduling a periodic task:</p><pre>import androidx.work.PeriodicWorkRequest<br>import java.util.concurrent.TimeUnit<br><br>val sendMessageWork = PeriodicWorkRequestBuilder&lt;SendMessageWorker&gt;(15, TimeUnit.MINUTES).build()<br>WorkManager.getInstance(this).enqueue(sendMessageWork)</pre><p>As you can see, we are using PeriodicWorkRequestBuilder class to create the periodic work request, passing in the SendMessageWorker class and the repeat interval of 15 minutes. It&#39;s worth noting that, unlike OneTimeWorkRequest, PeriodicWorkRequest will automatically reschedule itself after each execution, so you don&#39;t have to enqueue it multiple times.</p><p>Both of these examples are basic implementations, but Work Manager offers many more features that can be used to customize your tasks to fit the needs of your app. For example, you can chain multiple tasks together, schedule tasks to run at specific intervals, or set constraints on when the task should run like network connectivity, charging etc.</p><p>In conclusion, Android Work Manager is a powerful and easy-to-use library for scheduling background tasks on Android. It allows developers to perform tasks in the background without sacrificing battery life, and provides a wealth of tools and APIs for customizing tasks to fit the needs of your app. Give it a try in your next project and see how it can simplify your background task management.</p><p>Thank you for your time and please feel free to directly reach me in case of having any question or suggestion. 😇 😇</p><p><a href="https://www.linkedin.com/in/aligkts/">https://www.linkedin.com/in/aligkts/</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F26gsjCZpPolPr3sBy%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F26gsjCZpPolPr3sBy%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F26gsjCZpPolPr3sBy%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/95bc5663fc91522f184700841a98f49b/href">https://medium.com/media/95bc5663fc91522f184700841a98f49b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=674606ce6437" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitHub Actions ile Android CI/CD Entegrasyonu]]></title>
            <link>https://aligoktass.medium.com/github-actions-ile-android-ci-cd-entegrasyonu-ecaef8ab451a?source=rss-5c4d88745196------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecaef8ab451a</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[appcenter]]></category>
            <dc:creator><![CDATA[Ali Göktaş]]></dc:creator>
            <pubDate>Wed, 29 Dec 2021 13:36:45 GMT</pubDate>
            <atom:updated>2023-01-20T07:35:24.084Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba, <br>Bu yazımda android projemize GitHub Actions kullanarak nasıl CI/CD entegre edebileceğimizi anlatacağım.</p><p>Bir mobil developer olarak paket dağıtımı için ne kadar vakit harcadığınızı düşünün. Birçok aşamayı manuel olarak tamamlamak durumundasınız.</p><p>Projeyi derle, unit testleri çalıştır, <strong>apk</strong> veya <strong>aab</strong> dosyasını oluştur ve projede kullandığınız dağıtım platformuna(<strong>Firebase</strong>, <strong>AppCenter</strong> <strong>vs.</strong>) yükle.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o7TKEP6YngkCKFofC%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7TKEP6YngkCKFofC%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExN282bmR6cWp4Y3RkdGdzOW9sbm1seXF5OXRlOGtyY2E0OWplZ25ubSZlcD12MV9naWZzX2dpZklkJmN0PWc%2F3o7TKEP6YngkCKFofC%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="328" frameborder="0" scrolling="no"><a href="https://medium.com/media/afb6b9740b42f6ea895220040c234c8a/href">https://medium.com/media/afb6b9740b42f6ea895220040c234c8a/href</a></iframe><p>Bu tekrar eden süreç her yeni paket çıkarmak istediğimizde vaktimizi almaktadır.</p><p>CI/CD tam olarak bu vakit kaybına çözüm sunmaktadır. CI/CD entegrasyonu ile birlikte bu süreçlerin tamamını otomatize ederek bir hayli vakit kazanabiliriz.🤩🤩</p><h3>Continuous Integration(CI) Nedir?</h3><p>Kodda yapılan değişikliklerin çalışan sistem üzerinde herhangi bir probleme yol açmadığını tespit etmek için kullanılan bir yöntemdir. Sorunların tespiti için unit test, ui test, entegrasyon testi vs birçok yöntem kullanılabilir. Test sonucu çıkan bir hata, yapılan geliştirmenin sistemi bozduğunu gösterir. Temelde amaçlanan şey her geliştirme sonrasında ortaya çalışan bir sürüm çıkarabilmek diyebiliriz.</p><h3>Continuous Delivery(CD) Nedir?</h3><p>CI sürecini başarılı bir şekilde tamamlamış sürümün dağıtım yönteminin otomatize yoludur. Buradaki amaç ise herhangi bir efor harcamadan veya en az eforla test/prod ortamına paket dağıtmaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*xToiVy255zPINfXQ70qVzQ.png" /></figure><h3>Android Uygulamada CI/CD</h3><p>Sizlerle daha önce yazmış olduğum basit bir android not alma <a href="https://github.com/aligkts/NoteApplication">uygulamamıza</a> <a href="https://github.com/features/actions">GitHub Actions</a> kullanarak CI/CD entegre edeceğiz. Entegrasyon için adımlar tercihe ve ihtiyaca göre artırıp azaltılabilir. Örneğin; ui test, statik kod analizi vs. gibi şeyler eklenebilir ancak şu an örneği kompleksleştirmemek için temel adımlar üzerinden ilerleyeceğiz.</p><p>İzleyeceğimiz adımlar:</p><ul><li><strong>Lint Check</strong></li><li><strong>Unit Test</strong></li><li><strong>Generating APK</strong></li><li><strong>Deployment</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*n_xoyELhIWrPBiKgbuu40A.png" /></figure><p>Örneğimiz için belirttiğim üzere benim bir <a href="https://github.com/aligkts/NoteApplication">repomu</a> kullanacağız. Repo üzerinden Actions sekmesi aracılığıyla job ekleyeceğiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*WVcl3ZktCgyHO5SL2NEFEA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*EtlpsF0ICcfFRqgrdcAKxA.png" /></figure><h3>1.Lint Check</h3><p>Bu job master branchimize kod geldiğinde <strong>./gradlew lintDebug </strong>komutunu çalıştıracak ve sonuçları bir artifact olarak alıp belirlediğimiz pathe yükleyecek.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e27f0d59660c684eea649701250965c/href">https://medium.com/media/5e27f0d59660c684eea649701250965c/href</a></iframe><p>Mastera bir pr merge ettim ve gördüğünüz üzere mevcut jobumuz çalışmaya başladı. Detayları görmek için:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*IOePo5BwOdjeon83C6LLdQ.png" /></figure><p>Yml dosyamıza eklediğimiz lint jobu çalışıyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*Vmc3KOIjvMR3lRiAH_aXwg.png" /></figure><p>Tüm aşamalar problemsiz tamamlandığında şu şekilde bir görüntüye ulaşırız:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*LCaH3YvfphhGZdmXNd0Ilg.png" /></figure><p>Jobları tamamladıktan sonra Summary kısmından lint sonuçlarının artifactine ulaşıp detayları inceleyebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*U3zibBeshCVOOdb2yrpvuQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XQA9jXuI8eROGd8XoymBQQ.gif" /></figure><p>Gördüğünüz gibi lint uyarılarını detaylı bir şekilde html dosyası olarak çıktı alıyoruz. Böylece ilk adımımızı tamamladık.</p><h3>2.Unit Test</h3><p>Bu job ile birlikte projede yazmış olduğumuz unit testleri çalıştıracak olan <strong>./gradlew test </strong>komutunu çalıştıracağız. Test sonuçlarını da bir önceki adımdaki gibi bir html artifact olarak upload edeceğiz. Mevcut yml dosyamıza test için aşağıdaki jobu ekliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27db02350b6a6b1790f6e406dcbd09a6/href">https://medium.com/media/27db02350b6a6b1790f6e406dcbd09a6/href</a></iframe><p>Bu adımı da başarılı bir şekilde tamamlarsak aşağıdaki görüntüye ulaşırız.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*sC2orQxnYN7_QnDvpcRSng.png" /></figure><p>Çıkarılan artifact dosyamızda ise daha detaylı olarak testlerimizin sonuçlarına ulaşabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1HSJaJJ0AGJk7dvfGdxqDg.png" /></figure><h3>3.Generating APK</h3><p>Önceki adımların başarılıyla tamamlanmasının sonrasında bir apk oluşturulmasını istiyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d647bda7be2f3698ad1fe5341d3dcc86/href">https://medium.com/media/d647bda7be2f3698ad1fe5341d3dcc86/href</a></iframe><p>Bu job bir release paket oluşturup artifact olarak repoya upload edecektir. Daha sonraki adımda AppCenter ile bağladığımızda buraya ufak bir ekleme daha yapacağız.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*kj4L93_PXjopHWHo6NICgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*UfZ2Bi0tLo1GWfACrbv6gg.png" /></figure><h3>4.Deployment</h3><p>Artık apkmızı oluşturabiliyoruz. Bundan sonra paketi GitHub’a upload etmek yerine test edecek kişilere ulaştırma aşamamız kaldı. Bunun için çeşitli toollar var. Ben örneğimde sektörde de yaygın bir şekilde kullanılan <a href="https://github.com/marketplace/actions/app-center"><strong>AppCenter</strong></a>’i kullanacağım.</p><p>Öncelikle AppCenter’da bir üyelik açıp login olduktan sonra panele yeni bir uygulama ekliyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*dyUgxxgCTTfhTWeVzxB7jQ.png" /></figure><p>Sonrasında hesap ayarları kısmından bir token oluşturuyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*clabOz7v1ZuT9oLR1FP9TQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*J2OAts2gA_YTL87shmMfGA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*MXnQJnPX4FcJQSgWkqSfsA.png" /></figure><p>Token ekleme kısmını başarıyla tamamladıktan sonra aldığımız tokeni repository içerisine ekleyeceğiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4NH6cKuz6J3KefEZuPGpHw.png" /></figure><p>Secret adını vererek kendi tokeninizi bu şekilde ekleyebilirsiniz. Tokeni ekledikten sonra AppCenter distributionumuzu yapacak jobu ekliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/705f9169785db13a0d251948c4a7b585/href">https://medium.com/media/705f9169785db13a0d251948c4a7b585/href</a></iframe><p>Burada AppCenter’ın ücretsiz sürümünü kullandığım için herhangi bir test grubu oluşturamadım. Dolayısıyla group kısmında collaborators hedefledim. Siz varsa eğer kendi test grubunuzu yazabilirsiniz. Ek olarak appName kısmını da kendi uygulamanıza göre değiştirebilirsiniz. Ufak bir detay; buradaki path AppCenter kullanıcı adınız olacak şekilde değiştirilmelidir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*1nYBs7nLK4CppmOItln8Kw.png" /></figure><p>Artık master branchimize bir pr merge olunca otomatik olarak yeni paket ilgili kişilere iletilecektir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*WKzMBAG6cIYr9WX5EWPyRA.png" /></figure><p>Gördüğünüz üzere “Upload APK to App Center” aşaması başarıyla tamamlandı. AppCenter üzerinden de çıkan paketleri görebilirsiniz.🥳</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JhUgmXabNdntR4XuOk_G8w.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FAgrfqPt5AyiTm%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FAgrfqPt5AyiTm%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FAgrfqPt5AyiTm%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="257" frameborder="0" scrolling="no"><a href="https://medium.com/media/cfcf647ce5043ac393e789e5ea740c35/href">https://medium.com/media/cfcf647ce5043ac393e789e5ea740c35/href</a></iframe><p>Gördüğünüz gibi sizler de kendi uygulamalarınızda bu şekilde az bir eforla CI/CD kullanabilirsiniz. Vakit ayırıp yazımı okuduğunuz için teşekkürler. Yardımcı olabileceğim bir konu veya herhangi bir geri bildiriminiz olursa iletişime geçmenizden memnuniyet duyarım. 😇 🤩</p><ul><li><a href="https://github.com/aligkts/NoteApplication/blob/master/.github/workflows/main.yml">NoteApplication/main.yml at master · aligkts/NoteApplication</a></li><li><a href="https://www.linkedin.com/in/aligkts/">Ali Göktaş - Android Developer at Allianz Turkey - adesso Turkey | LinkedIn</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecaef8ab451a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Jetpack DataStore]]></title>
            <link>https://aligoktass.medium.com/android-jetpack-datastore-23ff00e04bab?source=rss-5c4d88745196------2</link>
            <guid isPermaLink="false">https://medium.com/p/23ff00e04bab</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Ali Göktaş]]></dc:creator>
            <pubDate>Mon, 20 Dec 2021 10:48:48 GMT</pubDate>
            <atom:updated>2022-07-12T13:28:37.075Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ikCjEvKCQ8kTn0m-Ts5O8A.png" /></figure><p>Merhaba,</p><p>Bu yazımda sizlere Android Jetpack ile gelen yeni bir veri depolama çözümü olan DataStore’dan bahsedeceğim.</p><p>Android Jetpack ile birlikte daha rahat kod yazabilmemizi sağlayan birçok library hayatımıza girdi. Bunlardan biri ise DataStore. Shared preferences yerine kullanılabilen yeni bir veri depolama çözümüdür. 2 farklı implementasyonu var. Gelin onlar neler bir bakalım.</p><ul><li><strong>Preferences DataStore:</strong> key value ile veriyi depolar.</li><li><strong>Proto DataStore: </strong>Verileri custom bir data tipinin nesnesi olarak depolar.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gnwx8u9zlthL51vguO7UZQ.png" /></figure><p>Bu yazımda Preferences DataStore üzerinde duracağım.</p><p><strong>Preferences DataStore</strong></p><p>İlk önce <a href="https://developer.android.com/topic/libraries/architecture/datastore#preferences-datastore">buradaki</a> linkten güncel dependenciyi projemize ekliyoruz.</p><p>Şimdi ise DataStoreRepository’imizi oluşturalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d9bbacb2c9d0137da6733d6ffb0cdd6/href">https://medium.com/media/5d9bbacb2c9d0137da6733d6ffb0cdd6/href</a></iframe><p>createDataStore fonksiyonu parametre olarak bir isim alacak.</p><p>preferencesKey&lt;String&gt; ile kaydedilecek veri için bir key oluşturuyoruz.</p><p>kaydedilen veriyi DataStore’dan okuma işlemini readName fonksiyonu ile, DataStore’a kaydetme işlemini saveName fonksiyonu ile yapıyoruz.</p><p>Sıra ViewModel oluşturmakta.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb5a45a5d4389596d9c7a3ab62c18dc8/href">https://medium.com/media/cb5a45a5d4389596d9c7a3ab62c18dc8/href</a></iframe><p>Repository içerisindeki save ve read fonksiyonlarını çağırabileceğimiz bir VM oluşturduk.</p><p>Son olarak Main Activity işlemlerimizi yapıyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8036b1b81a2ee9c8c5a2f8cd9080948a/href">https://medium.com/media/8036b1b81a2ee9c8c5a2f8cd9080948a/href</a></iframe><p>VM’yi de initialize ediyoruz.</p><p>Daha sonra name fieldini observe edip gelen değeri textviewa setliyoruz. Böylece SharedPreferences yerine DataStore ile uygulamamıza veri kaydetmiş olduk.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FvtVpHbnPi9TLa%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FvtVpHbnPi9TLa%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FvtVpHbnPi9TLa%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="245" frameborder="0" scrolling="no"><a href="https://medium.com/media/93b566878fdd0d45bef9a454a0f49342/href">https://medium.com/media/93b566878fdd0d45bef9a454a0f49342/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*RLSqhyR_q4JcdEY6YV4pfA.gif" /></figure><p>KAYNAKÇA:</p><p><a href="https://www.youtube.com/watch?v=hEHVn9ATVjY">https://www.youtube.com/watch?v=hEHVn9ATVjY</a></p><p><a href="https://www.simplifiedcoding.net/jetpack-datastore-tutorial/">https://www.simplifiedcoding.net/jetpack-datastore-tutorial/</a></p><p><a href="https://www.linkedin.com/in/aligkts/">Ali Göktaş - Android Developer at Allianz Turkey - adesso Turkey | LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23ff00e04bab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dagger Hilt ile Dependency Injection]]></title>
            <link>https://aligoktass.medium.com/dagger-hilt-ile-dependency-injection-ed577a65a74e?source=rss-5c4d88745196------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed577a65a74e</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[dagger-hilt]]></category>
            <dc:creator><![CDATA[Ali Göktaş]]></dc:creator>
            <pubDate>Mon, 20 Dec 2021 10:47:30 GMT</pubDate>
            <atom:updated>2021-12-20T10:47:30.738Z</atom:updated>
            <content:encoded><![CDATA[<p>Dependency Injection(DI), programlamada yaygın olarak kullanılan ve bağımlılığın minimize edilmesini sağlayan işlemdir. DI kullanarak iyi bir uygulama mimarisi, reusability ve test yazımına elverişli kod elde edebiliriz.</p><blockquote>DI temel prensibi, object instanceyi onu kullanacak classların içerisinde oluşturmak yerine dışarıdan provide etmektir.</blockquote><p>Android frameworküne gelecek olursak eğer, <a href="https://github.com/google/dagger"><strong>Dagger 2</strong></a> en çok kullanılan DI librarylerinden biridir. Alternatifi olarak <a href="https://github.com/InsertKoinIO/koin"><strong>Koin</strong></a><strong> </strong>ve <a href="https://github.com/Kodein-Framework/Kodein-DI"><strong>Kodein</strong></a>’i de inceleyebilirsiniz. Bugün sizlere Dagger kütüphanesinin en son sürümü olan <a href="https://developer.android.com/training/dependency-injection/hilt-android"><strong>Dagger Hilt</strong></a> ile ilgili bilgiler vereceğim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qlJbIlEb4dRmWeO46gAABg.jpeg" /></figure><p>Dagger Hilt’in nasıl çalıştığını ve Dagger 2&#39; ye göre ne gibi avantajlar sunduğunu anlamak için örnek bir implementasyon yapacağız.</p><h3>1. Dependency ekleme</h3><p>Projemize kütüphanenin dependencylerini ekliyoruz. Şu an itibariyle en güncel versiyonları ekliyorum ancak eklemeden önce en güncel sürümü <a href="https://developer.android.com/training/dependency-injection/hilt-android"><strong>linkten </strong></a>kontrol edip ekleyebilirsiniz.</p><p>Öncelikle project level <strong>build.gradle</strong> dosyamıza ekliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3661f7e927e22cd86211058640132d42/href">https://medium.com/media/3661f7e927e22cd86211058640132d42/href</a></iframe><p>Sonrasında app level build.gradle dosyamıza plugini ve dependencyleri ekliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82edd981baa6eafce6c9bc2bedef5b48/href">https://medium.com/media/82edd981baa6eafce6c9bc2bedef5b48/href</a></iframe><p><strong><em>Not:</em></strong><em> </em><a href="https://developer.android.com/training/dependency-injection/hilt-android"><em>Hilt </em></a><em>ve </em><a href="https://developer.android.com/topic/libraries/data-binding"><em>Data Binding</em></a><em> içeren projeler için </em><a href="https://developer.android.com/studio"><em>Android Studio</em></a><em> 4.0 ve üstü versiyonları kullanmalıyız.</em></p><p>Hilt Java 8 ile gelen yenilikleri kullanır. Bu nedenle projemizde Java 8&#39;i etkinleştirmek için app level gradle dosyamıza kodları ekliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07471963df184dec0010559b8305c7c1/href">https://medium.com/media/07471963df184dec0010559b8305c7c1/href</a></iframe><h3>2. Application Class</h3><p>Hilt kullanan tüm projeler <strong>@HiltAndroidApp</strong> annotationu eklenmiş bir Application classına sahip olmalıdır. Bu annotation, Hilt kodlarının generate edilmesini ve Application Lifecycle’ye eklenmesini sağlar. Application classımızı ekliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bb59b831169cc110b25a19d0e6e9ece/href">https://medium.com/media/6bb59b831169cc110b25a19d0e6e9ece/href</a></iframe><p>Manifest dosyamıza da application classımızı tanımlamayı unutmayalım.</p><pre><strong>android:name=&quot;.HiltSampleApplication&quot;</strong></pre><h3>3.Injection</h3><p>Dependency Injection’un temel prensibi olan injection, ihtiyaç duyulan classa ihtiyaç duyulan nesnenin Inject edilmesi olayıdır. Bağımlılığı azaltır ve test yazımını kolaylaştırır. <strong>Field Injection</strong> ve <strong>Constructor Injection</strong> olmak üzere iki farklı injection yöntemi bulunmaktadır.</p><p>Bildiğiniz üzere yakın zamanda<strong> </strong><a href="https://developer.android.com/reference/android/content/SharedPreferences"><strong>SharedPreferences</strong> </a>yerine <a href="https://developer.android.com/topic/libraries/architecture/datastore#preferences-datastore"><strong>DataStore </strong></a>duyurulmuştu. Örnek uygulamamda bir <strong>DataStore </strong>nesnesi ve bir username stringi provide edip app içinde her yerde kullanabilmeyi istiyorum. Bu nedenle <strong>DataModule.kt</strong> içerisine:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/942277acefabed9956ab5fe572abb82c/href">https://medium.com/media/942277acefabed9956ab5fe572abb82c/href</a></iframe><p>Dagger modüllerinin aksine Hilt modüllerinde, hangi modülün hangi classlarda kullanılacağını belirtmek için <strong>@InstallIn(ApplicationComponent::class) </strong>annotationunu kullanıyoruz.</p><p>Sonrasında provide edilen nesne ve değişkeni <strong>MainActivity.kt</strong> classımıza inject edeceğiz. Activity classına injection yapacağımız için öncelikle <strong>@AndroidEntryPoint </strong>annotationu ekliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd79cb82ac57992c725bcdea9947f72d/href">https://medium.com/media/fd79cb82ac57992c725bcdea9947f72d/href</a></iframe><p>Annotationlar ile ilgili kapsamlı bilgiye bu görsel yardımıyla ulaşabilirsiniz:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2F792P2DXSzgAO4n&amp;display_name=SlideShare&amp;url=https%3A%2F%2Fwww.slideshare.net%2FAliGkta1%2Fhilt-annotations&amp;image=https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_cropped_thumbnails%2Fhilt-annotations-201221182215%2Fthumbnail-large.jpg%3Fcb%3D1608574991&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e6be3cedcf333a3b85598d30abf438a/href">https://medium.com/media/1e6be3cedcf333a3b85598d30abf438a/href</a></iframe><p><strong>Username </strong>değişkenimizi ve <strong>DataStore </strong>nesnemizi inject ediyoruz :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88c5ab89f6b7bad368106511bd8c0b5d/href">https://medium.com/media/88c5ab89f6b7bad368106511bd8c0b5d/href</a></iframe><p>Injection işlemini tamamladık ve ikisini de MainActivity içerisinde kullanabilir haldeyiz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27491060a93e8ce1544b47611862b4b2/href">https://medium.com/media/27491060a93e8ce1544b47611862b4b2/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*RvEd6YIZBZ2Hsmfod_KIGQ.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FLYDNZAzOqrez6%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FLYDNZAzOqrez6%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FLYDNZAzOqrez6%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="398" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec4e0a8023e0559dd43e3ef239751b87/href">https://medium.com/media/ec4e0a8023e0559dd43e3ef239751b87/href</a></iframe><p>Bu yazımda sizlere Hilt ile DI konusunun en temel anlamda ne işe yaradığını anlatmaya çalıştım. Yardımcı olabileceğimi düşündüğünüz veya eksik gördüğünüz bir nokta olursa bana her zaman ulaşabilirsiniz.</p><p>Kaynak kodlara buradan erişebilirsiniz:</p><ul><li><a href="https://github.com/aligkts/DaggerHiltSample">aligkts/DaggerHiltSample</a></li><li><a href="https://www.linkedin.com/in/aligkts/">Ali Göktaş - Android Developer at Allianz Turkey - adesso Turkey | LinkedIn</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed577a65a74e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Navigation Component]]></title>
            <link>https://aligoktass.medium.com/android-navigation-component-b58b908d2f2b?source=rss-5c4d88745196------2</link>
            <guid isPermaLink="false">https://medium.com/p/b58b908d2f2b</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[architecture-components]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[navigation]]></category>
            <category><![CDATA[navigation-component]]></category>
            <dc:creator><![CDATA[Ali Göktaş]]></dc:creator>
            <pubDate>Fri, 01 Jan 2021 09:41:11 GMT</pubDate>
            <atom:updated>2021-12-27T14:19:59.712Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba. Bu yazımda sizlere <a href="https://developer.android.com/jetpack">Jetpack</a>’le gelen bir component olan Navigation’dan bahsedeceğim.</p><h3>Navigation</h3><p>Navigation component aslında bir varış noktası kavramıdır. Varış noktası (destination) ise uygulamada gitmek istenilen herhangi bir yerdir. Bu yer genellikle bir fragment veya activity’dir.</p><p>Navigationla beraber hayatımıza Navigation Graph, NavHost ve NavController gibi kavramlar girdi. Şimdi gelin beraber bu kavramların ne olduğuna bakalım.</p><p>👉 <strong>Navigation Graph:</strong> Kullanıcının uygulamada gidebileceği tüm olası destination’ları gösteren bir grafiktir.</p><p>👉 <strong>NavHost:</strong> Navigation Grap’taki destination’ların gösterileceği boş bir container’dır.</p><p>👉 <strong>NavController:</strong> Uygulamadaki NavHost içinde bulunan destination’ları yöneten bi nesnedir.</p><p>Bu kavramları da öğrendiğimize göre haydi projemize Navigation implement edelim.</p><h3>Navigation Implementation</h3><p><strong>1- </strong>Öncelikle dependency’lerimizi ekleyelim. Güncel haline <a href="https://developer.android.com/guide/navigation/navigation-getting-started">buradan</a> ulaşabilirsiniz.</p><p><strong>2- </strong>Daha sonra uygulamamıza iki tane boş fragment ekliyoruz. Ben FirstFragment ve SecondFragment diye iki tane ekledim. Sonra xml’lerin içini doldurdum.</p><p>FirstFragment.xml 👇</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c2a30280a4fe72c63cb5cbdd3019b4f/href">https://medium.com/media/7c2a30280a4fe72c63cb5cbdd3019b4f/href</a></iframe><p><strong>3- </strong>Şimdi bir Navigation Graph oluşturalım. <strong>Resources-&gt;New-&gt; AndroidResourceFile</strong> seçiyoruz. <strong>Resource type</strong> kısmında ise <strong>Navigation</strong> seçiyoruz. Böylece Navigation Graph’ımız oluşmuş oldu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gVHXnMIm4o6tKJrAXKXpvA.gif" /><figcaption>Navigation Oluşturma</figcaption></figure><p><strong>4- </strong>Artık Main Activity’mizi NavHost yapabiliriz. Bunun için activity_main.xml file’ımıza NavHost ekliyoruz.</p><p><strong>5-</strong> Navigation Graph’tan ise fragmentlarımızı ekliyoruz. Fragmentları ekledikten sonra FirstFragmenttan SecondFragmenta gideceğimizi göstermek için action’ımuzu ekliyoruz</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DtcbH9SSau8CzP0GHfF-fA.gif" /><figcaption>Fragmentları ve action’ı eklemek</figcaption></figure><p><strong>6-</strong> En son olarak artık First Fragmenttaki butona tıklandığında Second Fragmenta gitmesi için aksiyon yazacağız.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b86e0eeaf32448a7857a88e547ae2b6c/href">https://medium.com/media/b86e0eeaf32448a7857a88e547ae2b6c/href</a></iframe><p>Şu anda uygulamızda butona tıklandığında 2.fragmenta geçiyor.</p><p>Navigationla aynı zamanda veri taşıma da yapabiliyoruz. Şimdi uygulamamız üzerinden devam ederek Navigationla nasıl veri taşınıyor ona bakalım.</p><h3>Navigation ile Veri Taşıma</h3><p><strong>Data Göndermek</strong></p><p>Data taşımak için safeargs eklentisini eklememiz gerekiyor. Güncel haline <a href="https://developer.android.com/guide/navigation/navigation-getting-started">buradan</a> erişebilirsiniz.</p><p><strong>1- </strong>Öncelikle bir data classı oluşturuyoruz. Bu classta, isim ve soyisim bilgileri yer alacak. 2. fragmenta giderken bu bilgilerin taşınmasını istiyorum.</p><p>Data classımız:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22c1d0c7cad55750f8f590f0ecc0d865/href">https://medium.com/media/22c1d0c7cad55750f8f590f0ecc0d865/href</a></iframe><blockquote>Not: Veri taşımak için Parcelable yöntemini seçtim.</blockquote><p><strong>2-</strong> Daha sonra Navigation Graph üzerinden Second Fragmentımızı seçtikten sonra (nereye data taşıyacaksak o tarafı seçiyoruz) sol tarafta bulununan Attributes kısmından Arguments’i seçiyoruz. Buraya göndereceğimiz ismi ve hangi tipte göndereceğimizi belirtiyoruz. Daha sonra hangi classı göndereceğimizi seçiyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*2EueQXRicko5vdKmms5Kgg.gif" /><figcaption>Data Class Ekleme</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8hclERhNRAJ4sDhk5j2uA.png" /><figcaption>Gönderilecek olan Data Class</figcaption></figure><p><strong>3-</strong> Projemizi cleand and rebuild yaptıktan sonra action’ımız bir parametre isteyecek. Buraya ise biraz önce Argument eklerken oluşturduğumuz name’i veriyoruz. (yani burada information). Böylelikle data classımız gitmeye hazır.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9daf0a2d7c1607846161c09c772eb033/href">https://medium.com/media/9daf0a2d7c1607846161c09c772eb033/href</a></iframe><p>Datalarımızı taşıdık. Şimdiyse bu dataları diğer fragmentta nasıl alacağız ona bir bakalım.</p><p><strong>Data Karşılama</strong></p><p><strong>1- </strong>Data class’ımın tipinde bir değişken oluşturuyorum.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00f5cfec7a520c02006a77b26395343b/href">https://medium.com/media/00f5cfec7a520c02006a77b26395343b/href</a></iframe><p><strong>2-</strong> Verilerimizi arguments içinden alıyoruz. Arguments nullable olduğu için let ile kontrolunu yaptım. myName değişkenimizi SecondFragmentArgs sınıfımızdan fromBundle diyerek information’a eşitliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7d7c474a71c3d5cbf4b336078cf83f6/href">https://medium.com/media/d7d7c474a71c3d5cbf4b336078cf83f6/href</a></iframe><p>Son olarakta myName diyerek data classımızın içerisinde olan field’lara erişip onları kullanabiliyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*4tpcrHZ39B1zdteb2IoVAA.gif" /></figure><p>İşte Navigation ile uygulama içinde dolaşmak ve veri taşımak bu kadar kolay.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*wAr6eq02eIm7Dg8Os0Z8EQ.gif" /></figure><p>Bir sonraki yazımda görüşmek üzere…</p><p>Yararlandığım kaynak:</p><p><a href="https://developer.android.com/guide/navigation/navigation-getting-started">https://developer.android.com/guide/navigation/navigation-getting-started</a></p><p><a href="https://www.linkedin.com/in/aligkts/">Ali Göktaş - Android Developer at Allianz Turkey - adesso Turkey | LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b58b908d2f2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recyclerview Merge Adapter Kullanımı | Android]]></title>
            <link>https://aligoktass.medium.com/recyclerview-merge-adapter-kullan%C4%B1m%C4%B1-android-314e4b9c8205?source=rss-5c4d88745196------2</link>
            <guid isPermaLink="false">https://medium.com/p/314e4b9c8205</guid>
            <category><![CDATA[recyclerview]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mergeadapter]]></category>
            <category><![CDATA[architecture-components]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Ali Göktaş]]></dc:creator>
            <pubDate>Tue, 12 May 2020 08:15:45 GMT</pubDate>
            <atom:updated>2020-12-22T20:06:39.340Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ch2Wdw_53CI7I-X5PdDw8A.png" /></figure><p>Merhaba,</p><p>Sizden aşağıdakine benzer bir kullanıcı arayüzü tasarlamanızı istersem aklınıza gelen ilk düşünce ne olurdu?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*GPIvHNZ2VeE0U9UB8ctaQg.png" /></figure><p>Herkesin aklına farklı çözümler gelebilir fakat bu tür ekranlarda en yaygın yöntem Multiple ViewHolder kullanımıdır. Ancak bu çözümde farkı view tiplerini yönetmek geliştiricilere problem yaratabilmektedir. Verdiğim örnekte Header, Title ve Image olmak üzere 3 farklı view tipi bulunmaktadır.</p><p>Peki farklı view tiplerini yönetmeye zorunda kalmadan bu görünümü nasıl elde ederiz?</p><blockquote><a href="https://developer.android.com/reference/androidx/recyclerview/widget/MergeAdapter"><strong><em>Merge Adapter</em></strong></a></blockquote><p>Bu yazımda Merge Adapter kullanarak yukarıdaki ekranı nasıl elde edeceğimizi anlatacağım.</p><h3>📌1. Adım:</h3><p>Öncelikle MergeAdapter kullanabilmek için Recyclerview’a ihtiyaç duymaktayız. Bu nedenle app level <strong>build.gradle</strong> dosyamıza dependency eklememiz gerekmektedir.</p><pre>implementation “androidx.recyclerview:recyclerview:1.2.0-alpha03”</pre><h3>📌2. Adım:</h3><p>Örnek ekranımızda bulunan view tipleri için farklı model sınıflarını oluşturmalıyız.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4443bbc5713b039dd2fb82aae5fd7179/href">https://medium.com/media/4443bbc5713b039dd2fb82aae5fd7179/href</a></iframe><h3>📌3. Adım:</h3><p>Dummy datalara ihtiyaç duyuyoruz. Bu nedenle bize data sağlayacak bir object sınıfı oluşturuyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c33ce057da48295981a1c4a7fd7869ea/href">https://medium.com/media/c33ce057da48295981a1c4a7fd7869ea/href</a></iframe><h3>📌4. Adım:</h3><p>Recyclerview kullanımında, MergeAdapter bize sıralı olarak view tiplerinde item gösterebilmeyi sağlar. 3 farklı view tipimiz için adapter sınıflarını yazıyoruz:</p><p>Header gösterebilmek için HeaderAdapter oluşturuyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ce0acf1d0fa912511a87c98d05959e3/href">https://medium.com/media/8ce0acf1d0fa912511a87c98d05959e3/href</a></iframe><p>Header itemi için kullanacağımız <strong>item_header.xml </strong>şu şekilde:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff1f478cd48032efbf29f3f12b4531fd/href">https://medium.com/media/ff1f478cd48032efbf29f3f12b4531fd/href</a></iframe><p>Title gösterebilmek için TitleAdapter oluşturuyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da979c76f62436f8d944ee00aa1a371c/href">https://medium.com/media/da979c76f62436f8d944ee00aa1a371c/href</a></iframe><p>Title itemi için kullanacağımız <strong>item_title.xml</strong> şu şekilde:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00bef384a4ac3dedf88711274d257876/href">https://medium.com/media/00bef384a4ac3dedf88711274d257876/href</a></iframe><p>Son olarak, Image itemi gösterebilmek için ImageAdapter oluşturuyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6624dd815864d0fa8ff77fa7db747fa/href">https://medium.com/media/e6624dd815864d0fa8ff77fa7db747fa/href</a></iframe><p>Image itemi için kullanacağımız <strong>item_image.xml şu şekilde:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/257432f79e2d1a83d47d6cb026b85877/href">https://medium.com/media/257432f79e2d1a83d47d6cb026b85877/href</a></iframe><h3>📌5. Adım:</h3><p>Öncelikle <strong>activity_main.xml</strong> dosyası içerisine bir Recyclerview ekliyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d333619ad37f206e8942214a5ec5cf0e/href">https://medium.com/media/d333619ad37f206e8942214a5ec5cf0e/href</a></iframe><p><strong>MainActivity.kt</strong> içerisinde farklı adapterleri tanımlayıp, ardından bunları kullanabilmek için MergeAdapter oluşturacağız.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21bc0680597206370751df773107feb3/href">https://medium.com/media/21bc0680597206370751df773107feb3/href</a></iframe><p>Sonrasında, initRecyclerview() methodunu oluşturuyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/037704c2a15c98e56d80efa28ebb3575/href">https://medium.com/media/037704c2a15c98e56d80efa28ebb3575/href</a></iframe><p>Bu method içerisinde yazdığımız adapterleri dummy datalar ile initialize ediyor ve merge adapter constructoruna veriyoruz. Ardından tanımlamış olan merge adapterin recyclerview set işlemini tamamlıyoruz.</p><blockquote>Burada itemleri göstermek istediğimiz sıra ile MergeAdapter constructoruna vermemiz önemli bir detay.</blockquote><p>Uygulamayı çalıştırıyoruz ve aldığımız output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*ihONPTcXVIM6GEF6BDtvUQ.png" /></figure><p>Görüldüğü üzere sırasıyla view tiplerini verdik ve istediğimiz ekran çıktısını aldık :)</p><h3>Önemli Notlar:</h3><ol><li>Eğer aynı adapterı birden çok defa kullanmamız gerekirse multiple instances oluşturup MergeAdapter constructoruna vererek kullanabilirsiniz.</li></ol><p>2. Herhangi bir adapter için <strong>notifyDataSetChanged()</strong> çağırıldığında merge adapter için de tetiklenir.</p><p>Bu şekilde Merge Adapter bize farklı view tiplerini kolaylıkla yönetebilme imkanını sağlamıştır.</p><p>Vaktinizi ayırıp okuduğunuz için teşekkür ederim. Yardımcı olabileceğimi düşündüğünüz herhangi bir konu olursa bana ulaşabilirsiniz.</p><ul><li><a href="https://github.com/aligkts/MergeAdapterSample">aligkts/MergeAdapterSample</a></li><li><a href="https://www.linkedin.com/in/aligkts/">Ali Göktaş - Android Developer at Allianz Turkey - adesso Turkey | LinkedIn</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=314e4b9c8205" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Cloud Firestore REST API  ile Firebase Kütüphanesi Eklemeden Database Kullanımı]]></title>
            <link>https://aligoktass.medium.com/android-cloud-firestore-rest-api-ile-firebase-k%C3%BCt%C3%BCphanesi-eklemeden-database-kullan%C4%B1m%C4%B1-d461478a1f6c?source=rss-5c4d88745196------2</link>
            <guid isPermaLink="false">https://medium.com/p/d461478a1f6c</guid>
            <category><![CDATA[higher-order-function]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[firestore]]></category>
            <category><![CDATA[retrofit]]></category>
            <dc:creator><![CDATA[Ali Göktaş]]></dc:creator>
            <pubDate>Sun, 23 Jun 2019 19:45:17 GMT</pubDate>
            <atom:updated>2020-12-22T20:05:20.577Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android Cloud Firestore REST API</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*guMomxVVqRkT6FCKSDogAw.png" /></figure><p>Google, Firestore ile geliştiricilerin projelerine Firebase kitaplığını dahil etmek zorunda kalmadan database kullanmalarına izin verir. Bu kullanım size ileride verilerinizi başka bir servise taşımak istediğinizde kod içerisinde değişiklik yapmadan, sadece api url değişimi ile entegrasyonu yapma imkanını sunmaktadır.</p><h3>Firestore Nedir?</h3><p>Google’nin kompleks yapıdaki verileri saklamak ve hızlıca sorgulamak amacıyla geliştirdiği döküman tabanlı NoSql veritabanıdır. Firestore esnek bir yapıya sahiptir. Veriler istenilen şemada tutulabilir. Veriler document adı verilen yapılarda saklanır. Document topluluğuna ise collections adı veriliyor. Yapısı itibariyle diğer non relational veritabanlarına benzemektedir.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fah5tQ7yOh2s%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dah5tQ7yOh2s&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fah5tQ7yOh2s%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/770cc40041b135827259ab8d6f690972/href">https://medium.com/media/770cc40041b135827259ab8d6f690972/href</a></iframe><h3>Cloud Firestore vs Realtime Database</h3><p>Cloud Firestore, karmaşık verileri saklamak ve sorgulamak için daha gelişmiş çözümler sunuyor. Yani nested verileri saklarken ve sorgularken Cloud Firestore daha performanslı, ölçeklenebilir ve esnek bir yapı sağlıyor.</p><h3>Ne Yapacağız?</h3><p>Bugün Firestore içerisinde tuttuğunuz isim ve soyisim verisini, projemizde hiçbir Firebase kütüphanesi eklemeden fetch edip göstereceğiz.</p><p>Firestore’yi kullanmak için bir Firebase hesabına sahip olmak gereklidir. Hesabınız yoksa, aşağıdaki link yardımıyla oluşturabilirsiniz: <a href="https://firebase.google.com/">https://firebase.google.com</a></p><h3>Firestore Bağlantısı</h3><p><strong>Android Studio</strong>’yu açın ve <strong>Empty Activity</strong> ile yeni bir projeye başlayın.</p><p>Ardından <strong>Tools -&gt; Firebase</strong>’e tıklayın. Firebase Asistanı sağ panelde açılacaktır. Açılan panelden <strong>Firestore</strong>’yi seçin ve “<strong>Connect to Firebase</strong>” butonuna basın.Böylelikle projenizi Firebase ile ilişkilendirdiniz. Ardından “Add Cloud Firestore to your app” butonuna basarak dependency eklemelerinin yapılmasını bekleyin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bWic2lHrcc_wFAbGG04Qhw.png" /></figure><p>İlgili adımları tamamladıysanız eğer şuan projemize başlayabiliriz.</p><h3>Veri Ekleme</h3><p>Veritabanımıza basit bir veri ekleyeceğiz. Firebase konsolunu açarak database kısmına gelip Cloud Firestore’yi seçiyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Olcc8EBbQrtibTMTxmExg.png" /></figure><p>Örnek projemiz için test modunda başlatabilirsiniz fakat yapacağınız komplike bir uygulamada okuma, yazma izinlerini yönetmeniz gerekmektedir.</p><p>Yeni bir collection oluşturuyoruz ve içerisine bir data giriyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6IhnI7rbXYqW_T82CoCAhQ.png" /></figure><p>Eklediğimiz verilerin Json formatında çıktısına erişmek için linkte proje adınız ve collection isminizi girmeniz yeterlidir.</p><p>Firestore Rest Api için base url olarak <strong>https://firestore.googleapis.com/v1/projects/</strong> kullanılmaktadır.</p><p>Devamında <strong>projeadiniz/databases/(default)/documents/collectionadiniz </strong>ekleyerek verilerinize erişebilirsiniz.</p><p>Örnek uygulamamız için url şu şekildedir:</p><p><a href="https://firestore.googleapis.com/v1/projects/firestorerestapi/databases/(default)/documents/user"><strong>https://firestore.googleapis.com/v1/projects/firestorerestapi/databases/(default)/documents/user</strong></a></p><p><strong>Verilerimizin Json çıktısı:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d51mgJrpdb2MmtbxH2q3hw.png" /></figure><p>Şimdi yapmamız gereken sadece projemizde bir uzak sunucu bağlantısı kurup gelen Json verilerini parse etmektir. Ben bu projede request için <a href="https://square.github.io/retrofit/"><strong>Retrofit</strong></a> ve parse işlemi için <a href="https://github.com/google/gson"><strong>Gson</strong></a> kullanacağım. Bu kütüphaneleri kullanabilmek için app level <strong>build.gradle</strong> dosyasına aşağıdaki bağımlılıkları ekleyin:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ccde0243270657bf5bcccb9dc920f315/href">https://medium.com/media/ccde0243270657bf5bcccb9dc920f315/href</a></iframe><p>Öncelikle parse edeceğimiz Json yapısının model sınıflarını oluşturmalıyız. Burada Kotlin ile birlikte gelen <a href="https://kotlinlang.org/docs/reference/data-classes.html"><strong>Data Classes</strong></a>’ ı kullanacağım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/272e56f86997df9fe1c5779b020fc9b9/href">https://medium.com/media/272e56f86997df9fe1c5779b020fc9b9/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ae938ff428cce0178991e89adfd9cd8/href">https://medium.com/media/6ae938ff428cce0178991e89adfd9cd8/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dff5adea441d66fcf641670bbdd7fe16/href">https://medium.com/media/dff5adea441d66fcf641670bbdd7fe16/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac489d14ee9df32786306ef8c3b225c0/href">https://medium.com/media/ac489d14ee9df32786306ef8c3b225c0/href</a></iframe><p>Model sınıflarımızı ekledik. Şimdi Retrofit için Client sınıfımızı yaratacağız. Burada Kotlin’in bir yeniliği olan “<a href="https://kotlinlang.org/docs/tutorials/kotlin-for-py/objects-and-companion-objects.html"><strong>Companion Object</strong></a>” kullanacağız. Bu bize Singleton obje yaratmamızı sağlamaktadır.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8a18c85ebbcc225f0f52903c910ad7b/href">https://medium.com/media/a8a18c85ebbcc225f0f52903c910ad7b/href</a></iframe><p>Retrofit instance yarattığımıza göre şimdi linki tamamlayıp verileri çekebiliriz. Bunun için bir interface yaratıyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a3b68c5fdf585d37741e8a6fbcaf144/href">https://medium.com/media/6a3b68c5fdf585d37741e8a6fbcaf144/href</a></iframe><p>Şimdi Kotlin’in bize sunmuş olduğu başka bir kolaylık olan <a href="https://kotlinlang.org/docs/reference/lambdas.html"><strong>Higher Order Functions</strong></a>’ ları kullanarak bir Callback oluşturup, request sonucunda elde ettiğimiz parse edilmiş dataya kolaylıkla erişebileceğiz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4c8aa455ac82ee51f612965b869b8b3/href">https://medium.com/media/a4c8aa455ac82ee51f612965b869b8b3/href</a></iframe><p>Request atıp verilerimizi çektik. Methodumuz çağırılacağı yere lazım olan datayı gönderecektir.</p><p>Ana ekranımıza iki adet Textview koyarak gelen isim ve soyisim verilerini onlara set edeceğiz. Bunun için <strong>activity_main.xml</strong> dosyamıza componentleri ekleyeceğiz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45b9f19f76bd1b17529fab1f83755d02/href">https://medium.com/media/45b9f19f76bd1b17529fab1f83755d02/href</a></iframe><p>Şimdi eklediğimiz componentlere, uzak sunucudan çektiğimiz verileri atama zamanı. Bunun için öncelikle ApiClient sınıfımızdan bir obje oluşturmalıyız. Bu declaration işlemini <a href="https://kotlinlang.org/docs/reference/delegated-properties.html"><strong>Lazy Properties</strong></a> kullanarak tamamlıyoruz. Bunun sebebi sadece ihtiyaç duyduğumuzda bu objeyi tanımlayıp gereksiz yükü azaltmaktır.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ff070fe69ce05eb9c1ed1097f1f0cf1/href">https://medium.com/media/4ff070fe69ce05eb9c1ed1097f1f0cf1/href</a></iframe><p>Ardından ilgili methodun çağırımını yapıp elde ettiğimiz datayı componentlerimize atama işlemini yapıyoruz. Bu aşamada yine Kotlin’in güzelliklerinden olan <a href="https://kotlinlang.org/docs/reference/scope-functions.html"><strong>Scope Functions</strong></a> kullanımı ile kolaylıkla gelen datanın null kontrolünü yapıyoruz ve set ediyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03eb0377f97c447e7db9669b51e35325/href">https://medium.com/media/03eb0377f97c447e7db9669b51e35325/href</a></iframe><p>Son olarak internet izni almayı unutmayın :)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c039d21a034762ba10c71735ef766d91/href">https://medium.com/media/c039d21a034762ba10c71735ef766d91/href</a></iframe><h3>Sonuç:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*e6psyWYhCW_pHYJIJa4VDw.png" /></figure><h3>Özet :</h3><p>Sizlere Firestore içerisinde tuttuğumuz verileri Firebase’den bağımsız bir şekilde çekerek nasıl kullanabileceğimizi basit bir proje ile anlatmak istedim. Eğer projenizde Real Time Database’ye ihtiyaç duymayıp sadece belirli zamanlarda veri okuma, yazma işlemi yapıyorsanız, bu size çok yardımcı olacaktır. Ek olarak ileride karşılaşabileceğiniz değişikliklerde kod kısmında minimum eforu sarf etmenizi sağlayacaktır.</p><p>Bunun yanı sıra <strong>Kotlin</strong> ile gelen birkaç yeni özelliği de kullandım :</p><ul><li><a href="https://kotlinlang.org/docs/tutorials/kotlin-for-py/objects-and-companion-objects.html"><strong>Companion Object</strong></a></li><li><a href="https://kotlinlang.org/docs/reference/data-classes.html"><strong>Data Classes</strong></a></li><li><a href="https://kotlinlang.org/docs/reference/lambdas.html"><strong>Higher Order Functions &amp; Lambdas</strong></a></li><li><a href="https://kotlinlang.org/docs/reference/delegated-properties.html"><strong>Lazy Properties</strong></a></li><li><a href="https://kotlinlang.org/docs/reference/scope-functions.html"><strong>Scope Functions</strong></a></li></ul><p>Vaktinizi ayırıp okuduğunuz için teşekkür ederim. Yardımcı olabileceğimi düşündüğünüz herhangi bir konu olursa bana ulaşabilirsiniz.</p><p>Kaynak kodlara ulaşmak için:</p><ul><li><a href="https://github.com/aligkts/FirestoreRestApi">aligkts/FirestoreRestApi</a></li><li><a href="https://www.linkedin.com/in/aligkts/">Ali Göktaş - Android Developer at Allianz Turkey - adesso Turkey | LinkedIn</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d461478a1f6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Firebase ML Kit kullanarak Machine Learning]]></title>
            <link>https://aligoktass.medium.com/android-firebase-ml-kit-kullanarak-machine-learning-a9d9e4720c51?source=rss-5c4d88745196------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9d9e4720c51</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ali Göktaş]]></dc:creator>
            <pubDate>Sun, 16 Jun 2019 12:09:35 GMT</pubDate>
            <atom:updated>2020-12-22T20:10:36.388Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android Firebase ML Kit kullanarak Machine Learning-Face Detection</h3><p>Eskiden, Machine Learning teknolojisini kullanmak çok fazla hesaplama gücü ve ileri teknoloji donanım vb. gerektirdiğinden sadece cloud üzerinde mümkündü. Ancak günümüzde mobil cihazlar çok daha güçlü hale geldi ve algoritmalar daha verimli hale geldi. Bütün bunlar, Machine Learning’in bir bilimsel fonksiyon olmasının yanı sıra kendi cihazlarımızda da kullanabileceğimiz bir teknoloji haline dönüştürdü.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FwpKJpeOy-68%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DwpKJpeOy-68&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FwpKJpeOy-68%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4307903c65efcf8c2d3166772af0e6d6/href">https://medium.com/media/4307903c65efcf8c2d3166772af0e6d6/href</a></iframe><p>Cihazlar üzerinde makine öğrenmesi günümüzde birçok yerde kullanılmaktadır. Örneğin:</p><ul><li><strong>Akıllı Asistanlar: </strong>Cortana, Siri, Google Assistant gibi. Google Assistant bu yılki Google IO’da büyük bir güncelleme aldı ve cihazlardaki makine öğrenmesi yeteneklerini artırmaya ne kadar önem verdiğini gösterdi.</li><li><strong>Snapchat Filtreleri:</strong> Snapchat, insan yüzlerini tespit etmek ve gözlük, şapka, köpek filtresi vb. 3D filtreleri uygulamak için makine öğrenmesini kullanıyor.</li><li><strong>Akıllı Cevaplama: </strong>Akıllı cevaplama, bir mesaja yanıt olarak gönderilecek önceden oluşturulmuş bir mesaj şablonu sağlamak amacıyla, Whatsapp vb. gibi sohbet uygulamalarına dahil edilen bir cihaz özelliğidir.</li><li><strong>Google Lens: </strong>Google Lens, nesneleri tanımlamak ve etiketlemek için Machine Learning modellerini kullanır.</li></ul><p>Liste uzayıp gidebilir. Bu nedenle, bu yazıda, Android uygulamalarımızdaki makine öğrenme yeteneklerinin nasıl kullanılacağına ve daha akıllı hale geldiğine bir göz atacağız.</p><h3>Firebase ML Kit nedir?</h3><p><a href="https://firebase.google.com/products/ml-kit">Firebase ML Kit</a>, mobil geliştiricilerin uygulamalarına makine öğrenme yeteneklerini eklemelerini kolaylaştıran mobil bir SDK’dır. Aşağıdaki fonksiyonları barındırır:</p><ul><li><strong>Text Recognition:</strong> Resimlerden metin tanımak ve çıkarmak.</li><li><strong>Face Detection:</strong> Konturlarla birlikte yüzleri ve yüz işaretlerini tespit etmek.</li><li><strong>Object Detection and Tracking:</strong> To detect, track and classify objects in camera and static images.</li><li><strong>Image Labelling:</strong> Kameradaki ve statik görüntüdeki nesneleri algılamak, izlemek ve sınıflandırmak.</li><li><strong>Barcode scanning:</strong> Barkodları taramak ve işlemek.</li><li><strong>Landmark recognition:</strong> Görüntüdeki işaretleri tanımlama.</li><li><strong>Language ID:</strong> Metnin dilini tespit etmek.</li><li><strong>On-Device Translation:</strong> Metnin bir dilden diğerine çevrilmesi.</li><li><strong>Smart Reply:</strong> Önceki mesajlara dayalı metinsel cevaplar üretilmesi.</li></ul><p>Bunun dışında özel görüntü sınıflandırma makinesi öğrenme modellerini (<a href="https://www.tensorflow.org/lite/models">.tflite modelleri</a>) <strong>AutoML</strong> yardımıyla kullanabilirsiniz.</p><p>ML Kit, temel olarak mobil uygulamanıza makine öğrenme yeteneklerini dahil etme ve kullanma karmaşıklığını minimuma indirgeyen bir sistemdir.</p><h3>Ne yapacağız?</h3><p>Görüntüdeki yüzleri algılamak için ML Kit’in Yüz Algılama özelliğini kullanacağız. Görüntüyü kameramızdan çekip, üzerinde çıkarım yapıyor olacağız.</p><p>ML Kit’i kullanmak için bir Firebase hesabına sahip olmak gereklidir. Hesabınız yoksa, aşağıdaki link yardımıyla oluşturabilirsiniz: <a href="https://firebase.google.com/">https://firebase.google.com</a></p><h3>Firebase’de proje oluşturma</h3><p>Firebase’de bir hesap oluşturduktan sonra, <a href="https://console.firebase.google.com/">https://console.firebase.google.com</a> adresine gidin ve Add Project’e tıklayın.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SAE1VNJpY0-YgcGZGeVIZA.png" /></figure><p>Projenize bir isim verin ve “Create” a tıklayın. Projenizin hazır hale gelmesi birkaç saniye sürebilir.Ardından, devam edeceğiz ve projemize bir android uygulaması ekleyeceğiz</p><h3>Adding an app</h3><p><strong>Android Studio</strong>’yu açın ve <strong>Empty Activity</strong> ile yeni bir projeye başlayın.</p><p>Ardından <strong>Tools -&gt; Firebase</strong>’e tıklayın. Bu, Firebase Asistanını sağ panelde açacaktır. Açılan panelden, “Connect to Firebase” butonuna basın ve Firebase projenize giriş yapın. Android Studio’nun Firebase projenize erişmesine izin verdikten sonra bir proje seçmeniz istenir. Bir önceki adımda yarattığınızı seçin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*Pz-INyCM6Mb4LjNftTQ5tg.png" /></figure><p>Ardından projemize Face Detection implementasyonunu sağlayacağız:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AdcIacd57xln4IRpD9PPFQ.png" /></figure><p>Dependencies eklemeleri bittikten sonra uygulamamızı yazmaya başlayabiliriz.</p><h3>Configuring AndroidManifest.xml</h3><p>Android uygulamanızda çevrimdışı makine öğrenmesini sağlamak için <strong>androidmanifest.xml</strong> dosyasını değiştirmeniz gerekecektir.</p><p>Aşağıdaki <strong>meta-data</strong> ‘yı doğrudan uygulama etiketinizin altına ekleyin.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9fb9c88ca33ec34444c1db92a8a0a5e5/href">https://medium.com/media/9fb9c88ca33ec34444c1db92a8a0a5e5/href</a></iframe><p>Ayrıca, uygulamamıza kamera özelliği ekleyeceğiz, bu nedenle manifest içerisine kamera için izin etiketi ekleyin.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d43fef6ac7c1b998c6ade930b41894b/href">https://medium.com/media/1d43fef6ac7c1b998c6ade930b41894b/href</a></iframe><h3>Uygulamamıza kamera ekleme</h3><p>Kamerayı uygulamamıza eklemek için <a href="https://github.com/CameraKit/camerakit-android"><strong>CameraKit</strong></a>’ini kullanıyor olacağız. <a href="https://github.com/CameraKit/camerakit-android"><strong>Camerakit</strong></a>’i kullanmak için, app level <strong>build.gradle</strong> dosyasına aşağıdaki bağımlılıkları ekleyin:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6577278f25544b20b9dd91fccef44362/href">https://medium.com/media/6577278f25544b20b9dd91fccef44362/href</a></iframe><blockquote><strong>Not: Android uygulamasında Java ve Kotlin kullanıyorsanız Kotlin dependencyleri dahil edilmelidir.</strong></blockquote><p>Projeyi senkronize ettiğinizde eklediğiniz kütüphaneler indirilecektir.</p><p>Ardından, <strong>activity_main.xml</strong> layout dosyamıza bir CameraKitView ekleyeceğiz. Layout dosyasına aşağıdaki kodu ekleyin:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c71c916b73d97943a45d27c5661a36d/href">https://medium.com/media/1c71c916b73d97943a45d27c5661a36d/href</a></iframe><p>Ayrıca görüntüleri yakalamak için ekranın altına bir düğme ekleyin.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5761f09dca81f1865076304e0a84cad0/href">https://medium.com/media/5761f09dca81f1865076304e0a84cad0/href</a></iframe><h3>Kamera Konfigürasyonu</h3><p>Kamerayı, <strong>MainActivity.kt</strong> sınıfımızda initialize edeceğiz.Bunun için, bazı lifecycle methodlarını override edeceğiz ve kamera için bu methodları çağıracağız.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9a03b045ae272983b17e5af0dbd0162/href">https://medium.com/media/f9a03b045ae272983b17e5af0dbd0162/href</a></iframe><p>Android M’den itibaren izinleri çalışma zamanında sormamız gerekiyor. Bunu, <a href="https://github.com/CameraKit/camerakit-android"><strong>CameraKit</strong></a> kütüphanesi yardımıyla da çözebiliriz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb90d3fb9e81452efbdd7942cce6fe59/href">https://medium.com/media/eb90d3fb9e81452efbdd7942cce6fe59/href</a></iframe><h3>Fotoğraf Çekme</h3><p>Düğmeye basıldığında bir resim çekeceğiz ve resmi detektörümüze göndereceğiz. Ardından, yüzleri tespit etmek için görüntüye makine öğrenme modelini uygulayacağız.</p><p>Butona bir click listener ekliyoruz ve onClick içerisinde, captureImage fonksiyonunu çağırıyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a7515ebf52d819a93fb85723e505524/href">https://medium.com/media/1a7515ebf52d819a93fb85723e505524/href</a></iframe><p>ByteArray öğesinin bir Bitmap haline decode işlemini yapacağız ve Bitmap’i makul bir boyuta ölçekleyeceğiz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/031c4898cfeb8fc5167ff1a52b817447/href">https://medium.com/media/031c4898cfeb8fc5167ff1a52b817447/href</a></iframe><p>Artık dedektörümüzü bitmap üzerinde çalıştırmanın zamanı geldi. Bunun için <strong>runDetector ()</strong> methodunu oluşturuyoruz.</p><h3>Detection</h3><p>En güzel kısıma gelmiş bulunmaktayız. Yakalanan image üzerinde dedektörümüzü çalıştırıyor olacağız. Bunun için resimden bir FirebaseVisionImage oluşturmalıyız.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c7f064487180dcb2516895f01f2ce0a/href">https://medium.com/media/5c7f064487180dcb2516895f01f2ce0a/href</a></iframe><p>Ardından performanceMode, countourMode, landmarkMode vb. gibi bazı seçenekler eklemenin zamanı geldi.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/022e0722a13dcc63db5ee459b5735055/href">https://medium.com/media/022e0722a13dcc63db5ee459b5735055/href</a></iframe><p>Şimdi, bu seçenekleri kullanarak dedektörümüzü oluşturacağız.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6bbad5eabc710c5f212acc73700ef01/href">https://medium.com/media/f6bbad5eabc710c5f212acc73700ef01/href</a></iframe><p>Son olarak, algılamaya başlama zamanı. Dedektörü kullanarak detectInImage() fonksiyonunu çağırın ve görüntüyü iletin. Success ve Fail için Callback alacağız.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8028202d23d5fbc1ae0f0f8f74797f7/href">https://medium.com/media/d8028202d23d5fbc1ae0f0f8f74797f7/href</a></iframe><h3><strong>Sınırlayıcı</strong> kutu oluşturma</h3><p>Algılanan yüzlerde bir sınırlayıcı kutu oluşturmak için iki görünüm oluşturmamız gerekir. Birincisi, çizeceğimiz dikdörtgen üzerinde şeffaf bir görüntüdür. Sonraki gerçek görünüm.</p><p>GraphicOverlay.kt dosyası:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/428b4b8c6dde306625e5faac17cf6a99/href">https://medium.com/media/428b4b8c6dde306625e5faac17cf6a99/href</a></iframe><p>Asıl dikdörtgen sınırlayıcı görüntü:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdc9ccb7261ba720dcc48fcd6d3a7e08/href">https://medium.com/media/cdc9ccb7261ba720dcc48fcd6d3a7e08/href</a></iframe><p>Activity_main.xml layout dosyamıza bu graphicOverlay görünümünü ekleme zamanı:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8574c29f16052282ee13a6d51da31f47/href">https://medium.com/media/8574c29f16052282ee13a6d51da31f47/href</a></iframe><p>Activity_main.xml layoutumuzun son hali:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23258946c6320f1783d4408ed0fcd2fd/href">https://medium.com/media/23258946c6320f1783d4408ed0fcd2fd/href</a></iframe><p>Şimdi dikdörtgeni tespit edilen yüzlerin etrafına ekleme zamanı.Dedektörü kullanarak, processFaceResult () methodundan gelen yüzleri alıyoruz.</p><p>Aşağıdaki gibi her yüze bir kutu ekleyin:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13d53cd6eb846f8d8d678e4f73538d58/href">https://medium.com/media/13d53cd6eb846f8d8d678e4f73538d58/href</a></iframe><h3>Sonuç</h3><p>Uygulamamızın output ekranı:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*Coftku4LHxdxWAqE-V2Xvg.jpeg" /></figure><p>Vaktinizi ayırıp okuduğunuz için teşekkür ederim. Yardımcı olabileceğimi düşündüğünüz herhangi bir konu olursa bana ulaşabilirsiniz.</p><blockquote>Thanks to <a href="https://proandroiddev.com/">ProAndroidDev</a></blockquote><p>Kaynak kodlara ulaşmak için:</p><ul><li><a href="https://github.com/aligkts/FaceDetection">aligkts/FaceDetection</a></li><li><a href="https://www.linkedin.com/in/aligkts/">Ali Göktaş - Android Developer at Allianz Turkey - adesso Turkey | LinkedIn</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9d9e4720c51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Activity Lifecycle]]></title>
            <link>https://aligoktass.medium.com/android-activity-lifecycle-34ad04fe1e68?source=rss-5c4d88745196------2</link>
            <guid isPermaLink="false">https://medium.com/p/34ad04fe1e68</guid>
            <category><![CDATA[activity]]></category>
            <category><![CDATA[lifecycle]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Ali Göktaş]]></dc:creator>
            <pubDate>Sun, 16 Sep 2018 20:07:05 GMT</pubDate>
            <atom:updated>2020-12-22T20:11:26.085Z</atom:updated>
            <content:encoded><![CDATA[<p>İlk yazımda sizlere android activity lifecycle yapısı ve lifecycle callback methodlarından bahsedeceğim.</p><p>Öncelikle lifecycle callback methodlar şunlardır:</p><p>01. onCreate()<br>02. onStart()<br>03. onResume()<br>04. onPause()<br>05. onStop()<br>06. onDestroy()<br>07. onRestart()<br>08. onSaveInstanceState()<br>09. onRestoreInstanceState()</p><p>Bu methodların hangi sırayla çalıştığını kolaylıkla anlayabilmek için her birinin içerisine Log koymamız yeterlidir.</p><pre>@Override<br><strong>protected void </strong>onCreate(Bundle savedInstanceState) {<br>    <strong>super</strong>.onCreate(savedInstanceState);<br>    setContentView(R.layout.<strong><em>activity_main</em></strong>);<br>    Log.<em>i</em>(<strong>&quot;Activity lifecycle&quot;</strong>,<strong>&quot;onCreate&quot;</strong>);<br>}<br><br>@Override<br><strong>protected void </strong>onStart() {<br>    <strong>super</strong>.onStart();<br>    Log.<em>i</em>(<strong>&quot;Activity lifecycle&quot;</strong>,<strong>&quot;onStart&quot;</strong>);<br>}<br><br>@Override<br><strong>protected void </strong>onResume() {<br>    <strong>super</strong>.onResume();<br>    Log.<em>i</em>(<strong>&quot;Activity lifecycle&quot;</strong>,<strong>&quot;onResume&quot;</strong>);<br>}<br><br>@Override<br><strong>protected void </strong>onPause() {<br>    <strong>super</strong>.onPause();<br>    Log.<em>i</em>(<strong>&quot;Activity lifecycle&quot;</strong>,<strong>&quot;onPause&quot;</strong>);<br>}<br><br>@Override<br><strong>protected void </strong>onStop() {<br>    <strong>super</strong>.onStop();<br>    Log.<em>i</em>(<strong>&quot;Activity lifecycle&quot;</strong>,<strong>&quot;onStop&quot;</strong>);<br>}<br><br>@Override<br><strong>protected void </strong>onDestroy() {<br>    <strong>super</strong>.onDestroy();<br>    Log.<em>i</em>(<strong>&quot;Activity lifecycle&quot;</strong>,<strong>&quot;onDestroy&quot;</strong>);<br>}<br><br>@Override<br><strong>protected void </strong>onRestart() {<br>    <strong>super</strong>.onRestart();<br>    Log.<em>i</em>(<strong>&quot;Activity lifecycle&quot;</strong>,<strong>&quot;onRestart&quot;</strong>);<br>}<br><br>@Override<br><strong>protected void </strong>onSaveInstanceState(Bundle outState) {<br>    <strong>super</strong>.onSaveInstanceState(outState);<br>    Log.<em>i</em>(<strong>&quot;Activity lifecycle&quot;</strong>,<strong>&quot;onSaveInstanceState&quot;</strong>);<br>}<br><br>@Override<br><strong>protected void </strong>onRestoreInstanceState(Bundle savedInstanceState) {<br>    <strong>super</strong>.onRestoreInstanceState(savedInstanceState);<br>    Log.<em>i</em>(<strong>&quot;Activity lifecycle&quot;</strong>,<strong>&quot;onRestoreInstanceState&quot;</strong>);<br>}</pre><p>Yukarıdaki metotlardan 3 tanesi parametre olarak bundle objesi alıyor.Veri taşırken bu yaşam döngüsünde hangi metodun hangi sırayla çağrıldığını bilmek null değer almamızı engeller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*aL1Wm-K_EebgTtHyGaSN0A.png" /><figcaption><a href="https://developer.android.com/guide/components/activities/activity-lifecycle">https://developer.android.com/guide/components/activities/activity-lifecycle</a></figcaption></figure><h3>onCreate()</h3><p>Activity dosyaları ilk çalıştıklarında <strong>onCreate</strong> metodu devreye girer. Bu yüzden lifecyclede sadece bir defa çağırılır. Bu metotta genel olarak <strong>setContentView</strong> metodu çalıştırılarak bir layout dosyasından ekran tasarımı yüklenir. Eğer ekran ilk oluştuğunda tanımlanması gereken başka değişkenler ve aksiyonlar varsa, onlar da <strong>onCreate</strong> metodu içinde gerçekleştirilebilirler. Activity herhangi bir nedenden ötürü yok edilmezse (bellek ihtiyacı ya da <strong>finish</strong> metodu) bir daha çalıştırılmaz.</p><h3>onStart()</h3><p>onStart(),activity kullanıcı tarafından görünebilir olmaya başladığında tetiklenir.Yani onCreate() metodu çalıştırılıp görsel öğeler oluştuktan sonra çağırılır.</p><h3>onResume()</h3><p>Bu,uygulamanın kullanıcı ile etkileşime girdiği durumdur. Telefon başka bir etkileşim alana kadar uygulama bu aşamada durur. Örneğin;telefona çağrı gelmesi. onPause()’de bekleyen componentlerin devamı için burada tanımlamalısınız.</p><h3>onPause()</h3><p>Activity herhangi bir sebepten dolayı durdurulduysa (başka bir ekrana geçiş) tekrar ekrana geldiğinde bu metot harekete geçer. Activity çalıştırılmadan önce harekete geçen son metottur. Bu metottan sonra belirlenen koda göre Activity yaşamına başlar.</p><h3>onStop()</h3><p>Activity arka plana atıldığı anda işleme girer. Bu noktada iki seçenek vardır; ya kullanıcı yeni ekrandaki işini bitirip geri gelir ya da Activity tamamen kapatılır. Kullanıcı geri geldiği takdirde <strong>onRestart </strong>metoduna geçilir ve döngü <strong>onStart</strong> metodundan tekrar başlar. Eğer kullanıcı geri gelmeyecekse <strong>onDestroy</strong> metodu çalıştırılır.</p><h3>onDestroy()</h3><p>Activity’e ait bütün kaynaklar yok edilir. Activity bu noktada yaşam döngüsünü tamamlamıştır.Activity tekrar kullanılmak istediğinde onCreate metodundan başlar.</p><h3>onRestart()</h3><p>onRestart() geri tuşuna basıldığında ve uygulama tekrardan açıldığında tetiklenir.</p><h3>onSaveInstanceState()</h3><p>Aktivitenin durumu hakkında ek verileri kaydetmek için,<strong>onSaveInstanceState() </strong>geri çağırma metodu kullanılmalıdır. Kullanıcı aktiviteyi terk ettiği zaman sistem bu metodu çağırır ve aktivitenin beklenmedik bir şekilde kapanması durumunda durum verileri Bundle nesnesine kaydedilir. Aktiviteyi tekrar oluşturma ihtiyacı doğduğunda sistem aynı Bundle nesnesini hem<strong> onRestoreInstanceState()</strong> hem de <strong>onCreate() </strong>metotlarına iletir.Bu metotta bulunan bundle ekranı dikeyden yataya çevirince verilerin kaybolmasının engellenmesi için kullanılabilecek birkaç veri taşıma yönteminden biridir.</p><pre>@Override<br><strong>protected void </strong>onSaveInstanceState(Bundle outState) {<br>    <strong>super</strong>.onSaveInstanceState(outState);<br>    outState.putString(itemName, itemValue);<br>}</pre><h3>onRestoreInstanceState()</h3><p>onRestoreInstanceState() ,onStart() ve onResume() arasında çağırılır. Bundle objesine bu metodu kullanarak tekrar ulaşabilirsiniz. Bundleye onCreate içerisinde de ulaşabilirsiniz fakat bu durumda null check yapmanız gerekir. <strong>onRestoreInstanceState()</strong> metodunda view hiyerarşinin korunması için her zaman öncelikle superclass çağırılır.</p><pre>@Override<br><strong>protected void </strong>onRestoreInstanceState(Bundle savedInstanceState) {<br>    <strong>super</strong>.onRestoreInstanceState(savedInstanceState);<br>    value = savedInstanceState.getString(itemName);<br>    textView.setText(value);<br>}</pre><pre>@Override<br><strong>protected void </strong>onCreate(Bundle savedInstanceState) {<br>    <strong>super</strong>.onCreate(savedInstanceState);<br>    setContentView(R.layout.<strong><em>activity_main</em></strong>);<br>    <strong>if</strong>(savedInstanceState != <strong>null</strong>){<br>        value = savedInstanceState.getString(itemName);<br>        textView.setText(value);<br>    }</pre><pre>}</pre><p><strong>Activity lifecycles çalışma mantığını daha iyi kavrayabilmek için:</strong></p><p><strong>Uygulama açıldığında</strong></p><p>onCreate() --&gt; onStart() --&gt; onResume()</p><p><strong>Geri tuşuna basıldığında</strong></p><p>onPaused() -- &gt; onStop() --&gt; onDestroy()</p><p><strong>Home tuşuna basıldığında</strong></p><p>onPaused() --&gt; onStop()</p><p><strong>Home tuşuna basıp son uygulamalardan açtığımızda veya uygulamamızın ikonuna basarak açtığımızda</strong></p><p>onRestart() --&gt; onStart() --&gt; onResume()</p><p><strong>Üst bildirim ekranından başka bir uygulama açtığımızda veya ayarları açtığımızda</strong></p><p>onPaused() --&gt; onStop()</p><p><strong>Başka bir uygulamada isek geri butonuna bastığımızda veya ayarlarda isek geri butonuna bastığımızda</strong></p><p>onRestart() --&gt; onStart() --&gt; onResume()</p><p><strong>Ekranda herhangi bir dialog ekranı açıldığında</strong></p><p>onPause()</p><p><strong>Dialog ekranını kapattığımızda veya geri tuşuna bastığımızda</strong></p><p>onResume()</p><p><strong>Telefon ekranı kapandığında</strong></p><p>onPaused() --&gt; onStop()</p><p><strong>Telefon ekranı tekrar açıldığında</strong></p><p>onRestart() --&gt; onStart() --&gt; onResume()</p><p><a href="https://www.linkedin.com/in/aligkts/">Ali Göktaş - Android Developer at Allianz Turkey - adesso Turkey | LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34ad04fe1e68" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>