<?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 Sezer Özaltun on Medium]]></title>
        <description><![CDATA[Stories by Sezer Özaltun on Medium]]></description>
        <link>https://medium.com/@sezerozaltunn?source=rss-d31aaf4017d7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*o-xawOwAVC81q6qsIhM5Rw.jpeg</url>
            <title>Stories by Sezer Özaltun on Medium</title>
            <link>https://medium.com/@sezerozaltunn?source=rss-d31aaf4017d7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 17:13:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sezerozaltunn/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[Editing Image Using HMS (ML Kit, Cloud Storage, Auth Service) Android — Kotlin]]></title>
            <link>https://medium.com/huawei-developers/editing-image-using-hms-ml-kit-cloud-storage-auth-service-android-kotlin-e27f23b3a918?source=rss-d31aaf4017d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/e27f23b3a918</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[hms]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Sezer Özaltun]]></dc:creator>
            <pubDate>Wed, 17 May 2023 11:39:07 GMT</pubDate>
            <atom:updated>2023-05-17T11:39:07.787Z</atom:updated>
            <content:encoded><![CDATA[<h3>Editing Image Using HMS (ML Kit, Cloud Storage, Auth Service) Android — Kotlin</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bI6ZHj3EUi1XrLAQfWm0Ag.png" /><figcaption>Huawei Services Used in the Project</figcaption></figure><h3>Introduction</h3><p>Hello everyone, I’m here with the new article. In this article, I will explain how to remove the background of your images using ML Kit, Cloud Storage, and Auth Service from Huawei mobile services.</p><p>We will remove the background of the images using the <strong>ML Kit</strong></p><p>We will securely upload the photos we edited using <strong>Cloud Storage</strong> to the cloud, and we will have the opportunity to access them from anywhere. We will use the upload, download, and delete listing features, which are Cloud Storage processes.</p><p><strong>Auth Service</strong>, on the other hand, will be needed for authentication in the use of Cloud Storage.</p><h3>Integration of Services</h3><p>Before starting the coding part, you need to integrate HMS Core into your application. You can click the link <a href="https://medium.com/huawei-developers/android-integrating-your-apps-with-huawei-hms-core-1f1e2a090e98">here </a>for this.</p><p>There are a few steps we need to take to integrate the services into our project.</p><p><strong>1.</strong> Sign in to AppGallery Connect and click My Projects</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*NMAgqtNVB0vGRQOsKPcQPg.png" /><figcaption>AppGallery Connect My Projects</figcaption></figure><p><strong>2.</strong> Click your project card and select the app for which you want to enable a service from the app drop-down list on the top.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*-SttYoQ3dztbyCQv8uowSA.png" /><figcaption>Selecting Project</figcaption></figure><p><strong>3. </strong>To use ML Kit and Auth Service, click on Manage APIs tab, and enable ML Kit and Auth Service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*eZv2gjm5ETKuubD1WiBdMA.png" /><figcaption>Enable ML Kit</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*rzlS3HpUVxs2fZQRiWGsmw.png" /><figcaption>Enable Auth Service</figcaption></figure><p><strong>4</strong>. To use Cloud Storage, we need to perform the following steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*BsUUBdAckS5rKnzSqfdQbg.png" /><figcaption>Enable Cloud Storage</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*17iseRZX6R-ooMBQOjQSaA.png" /><figcaption>Set Instance and location</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*7Dx_e2--vFsodf7gh12CJQ.png" /><figcaption>Finish the integration of Cloud Storage</figcaption></figure><p><strong>5.</strong> Let’s add the necessary permissions to the AndroidManifest.xml file in Android Studio.</p><pre>&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt; <br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;<br>&lt;application<br>      android:allowBackup=&quot;false&quot;<br>      android:requestLegacyExternalStorage=&quot;true&quot;<br>.<br>.<br>. &lt;meta-data<br>android:name=&quot;com.huawei.hms.ml.DEPENDENCY&quot;<br>android:value=&quot;imgseg&quot; /&gt;<br>&lt;/application&gt;</pre><p><strong>6. </strong>Let’s add the necessary dependencies in the build.gradle.</p><pre>//Huawei Auth<br>    implementation &#39;com.huawei.agconnect:agconnect-auth:1.6.5.300&#39;<br>    //Ml Kit<br>    implementation &#39;com.huawei.hms:ml-computer-vision-segmentation:3.7.0.302&#39;<br>    // Import the multiclass segmentation model package.<br>    implementation &#39;com.huawei.hms:ml-computer-vision-image-segmentation-multiclass-model:3.7.0.302&#39;<br>    // Import the human body segmentation model package.<br>    implementation &#39;com.huawei.hms:ml-computer-vision-image-segmentation-body-model:3.7.0.302&#39;<br>    // Import the hair segmentation model package.<br>    implementation &#39;com.huawei.hms:ml-computer-vision-image-segmentation-hair-model:3.7.0.302&#39;<br>    //Cloud Storage<br>    implementation &quot;com.huawei.agconnect:agconnect-storage:1.5.0.100&quot;</pre><h3>Implementation</h3><p>Until now, we have enabled the necessary services via AppGallery Connect and added the necessary dependencies to our project. If you have encountered any errors or want to examine them in more detail, you can review the relevant resources in the references section at the end of the article.</p><h4>ML Kit Implementation</h4><pre>var setting = MLImageSegmentationSetting.Factory()<br>            .setExact(true)<br>            .setAnalyzerType(MLImageSegmentationSetting.BODY_SEG)<br>            .setScene(MLImageSegmentationScene.FOREGROUND_ONLY)<br>            .create()<br>        analyzer = MLAnalyzerFactory.getInstance().getImageSegmentationAnalyzer(setting)<br>        val drawable: BitmapDrawable = binding.imageView.drawable as BitmapDrawable<br>        bitmap = drawable.bitmap<br>        val mlFrame = MLFrame.Creator().setBitmap(bitmap).create()<br>        val task: Task&lt;MLImageSegmentation&gt; = analyzer.asyncAnalyseFrame(mlFrame)<br>        task.addOnSuccessListener {<br>            removeBackGround(it)<br>        }.addOnFailureListener {<br>            Log.e(TAG1, &quot;analyse -&gt; asyncAnalyseFrame: &quot;, it)<br>        }</pre><p>We create a new segmentation with the above lines of code. Here, we set the internal analyzer type to BOD_SEG and setScene to FOREGROUND_ONLY to keep human analysis and only foreground permissions. Then we select our image with the bitmap and run the removeBackGround method when the task is successful.</p><pre>private fun removeBackground(mlImageSegmentation: MLImageSegmentation?) {<br>        if (mlImageSegmentation != null) {<br>            if (bitmap == null) {<br>                Log.e(TAG1, &quot;bitmap is null&quot;)<br>                return<br>            }<br>            val bitmapFore: Bitmap = mlImageSegmentation.getForeground()<br>            if (bitmapFore != null) {<br>                binding.imageView.setImageBitmap(bitmapFore)<br>            } else {<br>                Log.e(TAG1, &quot;bitmap is null&quot;)<br>            }<br>        }<br>    }</pre><p>In the removeBackGround method, we delete the background of the image we sent with the bitmap with the MLImageSegmentation class.</p><h4>Auth Service Implementation</h4><p>The purpose of using Auth Service is that Cloud Storage requests an authentication while using it.</p><pre>if (AGConnectAuth.getInstance().currentUser != null) {<br>            DriverManager.println(&quot;already sign a user&quot;)<br>            Log.i(TAG2, &quot;already sign a user&quot;)<br>            return<br>        } else {<br>            AGConnectAuth.getInstance().signInAnonymously()<br>                .addOnSuccessListener {<br>                    DriverManager.println(&quot;AGConnect OnSuccess&quot;)<br>                    Log.i(TAG2, &quot;AGConnect OnSuccess&quot;)<br>                }<br>                .addOnFailureListener { e -&gt;<br>                    DriverManager.println(&quot;AGConnect OnFail: &quot; + e.message)<br>                    Log.i(TAG2, &quot;AGConnect OnFail ${e.message}&quot;)<br>                }<br>        }</pre><p>Using the above line of code, we log in anonymously and can use Cloud Storage. You can also log in as a real user if you want.</p><h4>Cloud Storage Implementation</h4><p>First of all, we need to get write and read permissions with the following code.</p><pre>1. private val permissions = arrayOf&lt;String&gt;(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE)<br>2. ActivityCompat.requestPermissions(this, permissions, 1)</pre><p>After that, we need to get an instance with storage management in order to use Cloud Storage. This instance will provide our connection to the Cloud.</p><pre>private var mAGCStorageManagement: AGCStorageManagement? = null<br>val storageManagement = AGCStorageManagement.getInstance()<br>private fun initAGCStorageManagement() {<br>        mAGCStorageManagement = AGCStorageManagement.getInstance()<br>        Log.i(TAG2, &quot;Init AGC Storage Management success! &quot;)<br>    }</pre><h4>Cloud Storage Upload</h4><p>With the following line of code, we can upload our images to the Cloud side. The path here is the name of the file to be created on the cloud side.</p><pre>val progressDialog = ProgressDialog(this)<br>        progressDialog.setMessage(&quot;Uploading File....&quot;)<br>        progressDialog.setCancelable(false)<br>        progressDialog.show()<br>        val systemCurrentTime: Long = System.currentTimeMillis()<br>        val path = &quot;/images/${systemCurrentTime}.png&quot;<br>        val agcSdkDirPath = agcSdkDirPath<br>        val file = File(agcSdkDirPath)<br>        if (!file.exists()) {<br>            Log.i(TAG2, &quot;file is not exist!&quot;)<br>            return<br>        } else {<br>            Log.i(TAG2, &quot;file is exist&quot;)<br>            val storageReference =<br>                mAGCStorageManagement!!.getStorageReference(path)<br>            val uploadTask = storageReference.putFile(file)<br><br>            uploadTask.addOnSuccessListener {<br>                Log.i(TAG2, &quot;upload success!&quot;)<br>                progressDialog.dismiss()<br>            }<br>                .addOnFailureListener { e: Exception -&gt;<br>                    progressDialog.dismiss()<br>                    Log.i(<br>                        TAG2,<br>                        &quot;Upload Failed $e&quot;<br>                    )<br>                }<br>        }<br>private val agcSdkDirPath: String<br>        get() {<br>            DriverManager.println(&quot;path=$path&quot;)<br>            val dir = File(path)<br>            if (!dir.exists()) {<br>                dir.mkdirs()<br>            }<br>            return path!!<br>        }</pre><h4>Cloud Storage Listing Files</h4><p>With the following lines of code, we can view the files we have uploaded to “images/ “ folders and list them on the list.</p><pre>val path = &quot;images/&quot;<br>        val storageReference = mAGCStorageManagement?.getStorageReference(path)<br>        var listResultTask: Task&lt;ListResult&gt;? = null<br>        listResultTask = storageReference?.list(100)<br>        listResultTask?.addOnSuccessListener {<br>            fileList = ArrayList(it.fileList)<br>            mAdapter = DownloadListAdapter(<br>                this@DownloadListActivity,<br>                fileList = fileList,<br>                mAGCStorageManagement,<br>                this@DownloadListActivity<br>            )<br>            binding.recyclerView.adapter = mAdapter<br>            mAdapter.notifyDataSetChanged()<br><br>            Log.i(&quot;MYSTORAGE&quot;, &quot;SUCCEDD: ${fileList.size}&quot;)<br>        }?.addOnFailureListener {<br>            Log.e(&quot;MYSTORAGE&quot;, &quot;FAIL: ${it.printStackTrace()}&quot;)<br>        }<br>    }</pre><h4>Cloud Storage Download</h4><p>When we want to download any of our files from the Cloud, we need to define the path and name of that file correctly. For this, I defined the agcSdkDirPath and fileName parameters to the File method and I send a file download request with storageReference.getFile(file).</p><pre>val progressDialog = ProgressDialog(context)<br>        progressDialog.setMessage(&quot;Downloading File....&quot;)<br>        progressDialog.setCancelable(false)<br>        progressDialog.show()<br>        val fileName = fileName<br>        val path = path<br>        val agcSdkDirPath = agcSdkDirPath2<br>        val file = File(agcSdkDirPath, fileName)<br>        val storageReference = mAGCStorageManagement!!.getStorageReference(path)<br>        val downloadTask = storageReference.getFile(file)<br>        downloadTask.addOnSuccessListener {<br>            Toast.makeText(context, &quot;Download Succeed&quot;, Toast.LENGTH_SHORT).show()<br>            progressDialog.dismiss()<br>        }.addOnFailureListener { e: Exception -&gt;<br>            Toast.makeText(context, &quot;Download Error&quot;, Toast.LENGTH_SHORT).show()<br>            progressDialog.dismiss()<br>            Log.i(&quot;MYSTORAGE&quot;, &quot;DOWNLOAD ERROR: $e&quot;)<br>        }<br>private val agcSdkDirPath2: String<br>        get() {<br>            val path =<br>                Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).absoluteFile.toString()<br>            DriverManager.println(&quot;path=$path&quot;)<br>            val dir = File(path)<br>            if (!dir.exists()) {<br>                dir.mkdirs()<br>            }<br>            return path<br>        }</pre><h4>Cloud Storage Delete</h4><p>As in downloading a file, the path must be given correctly and the storageReference.delete() method must be called.</p><pre>val path = path<br>        DriverManager.println(&quot;path=%s$path&quot;)<br>        val storageReference = mAGCStorageManagement!!.getStorageReference(path)<br>        val deleteTask = storageReference.delete()<br>        deleteTask.addOnSuccessListener {<br>            Toast.makeText(context, &quot;Delete Succeed&quot;, Toast.LENGTH_SHORT).show()<br>            activity.getAllList()<br>            notifyDataSetChanged()<br><br>        }<br>            .addOnFailureListener { e: Exception -&gt;<br>                Toast.makeText(context, &quot;Delete Error:&quot;, Toast.LENGTH_SHORT).show()<br>                Log.i(&quot;MYSTORAGE&quot;, &quot;DELETE ERROR: $e&quot;)<br>            }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wnIl7VynOwkxaUnXwrcVkw.png" /><figcaption>Screenshots</figcaption></figure><h3>Conclusion</h3><p>In this article, we have removed the background of images using ML Kit. We uploaded the photos that we removed the background using Cloud Storage to the Cloud side, and performed the listing and deletion of our images. I hope it was a useful article for you.</p><h3>References</h3><ul><li><a href="https://github.com/huaweicodelabs/multi-kit-codelabs/tree/main/ImageBGCleaner">multi-kit-codelabs/ImageBGCleaner at main · huaweicodelabs/multi-kit-codelabs</a></li><li><a href="https://developer.huawei.com/consumer/en/hms/huawei-mlkit/">ML Kit - Machine Learning Service - HUAWEI Developer</a></li><li><a href="https://developer.huawei.com/consumer/en/agconnect/auth-service/">Auth Service - HUAWEI Developers</a></li><li><a href="https://developer.huawei.com/consumer/en/agconnect/cloud-storage/">Cloud Storage - HUAWEI Developers</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e27f23b3a918" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/editing-image-using-hms-ml-kit-cloud-storage-auth-service-android-kotlin-e27f23b3a918">Editing Image Using HMS (ML Kit, Cloud Storage, Auth Service) Android — Kotlin</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HMS Kullanarak Resimlerinizi Düzenleyin (ML Kit, Cloud Storage, Auth Service) Android - Kotlin]]></title>
            <link>https://medium.com/huawei-developers-tr/hms-kullanarak-resimlerinizi-d%C3%BCzenleyin-ml-kit-cloud-storage-auth-service-android-kotlin-103493125cb2?source=rss-d31aaf4017d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/103493125cb2</guid>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[hms]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Sezer Özaltun]]></dc:creator>
            <pubDate>Wed, 17 May 2023 11:38:59 GMT</pubDate>
            <atom:updated>2023-05-17T11:38:59.367Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bI6ZHj3EUi1XrLAQfWm0Ag.png" /><figcaption>Projede Kullanılan Huawei Servisleri</figcaption></figure><h3><strong>Giriş</strong></h3><p>Herkese merhaba, yeni bir içerikle karşınızdayım. Bu makalede Huawei mobil servislerinden ML Kit, Cloud Storage ve Auth Service kullanarak fotoğraflarınızın arka planını nasıl kaldıracağınızı anlatacağım.</p><p><strong>ML Kit</strong> ile fotoğrafın arka planını kaldıracağız</p><p><strong>Cloud Storage </strong>kullanarak düzenlediğimiz fotoğrafları güvenli bir şekilde cloud’a yükleyeceğiz ve her yerden erişebilme imkanımız olacak. Cloud Storage işlemeri olan upload, download, delete ve listeleme özelliklerini kullacağız.</p><p><strong>Auth Service</strong> ise bize Cloud Storage kullanımında authentication için lazım olacak.</p><h3>Servislerin Entegre Edilmesi</h3><p>Kodlama kısmına başlamadan önce uygulamanıza HMS Core entegre etmeniz gerekiyor. Bunun için <a href="https://medium.com/huawei-developers-tr/android-uygulamalar%C4%B1n%C4%B1za-huawei-hms-core-entegre-edin-542476f58910"><em>buradaki</em></a><em> </em>bağlantıya tıklayabilirsiniz.</p><p>Servisleri projemize entegre etmek için yapmamız gereken birkaç adım bulunmakta.</p><p><strong>1.</strong> AppGallery Connect’e giriş yapın ve My Projects’e tıklayın.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*NMAgqtNVB0vGRQOsKPcQPg.png" /><figcaption>AppGallery Connect My Projects</figcaption></figure><p><strong>2.</strong> Servisleri kullanmak istediğiniz projeyi seçin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*-SttYoQ3dztbyCQv8uowSA.png" /><figcaption>Proje seçme</figcaption></figure><p><strong>3. </strong>ML Kit ve Auth Service kullanabilmek için Manage APIs sekmesine tıklayın, ML Kiti ve Auth Service aktifleştirin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*eZv2gjm5ETKuubD1WiBdMA.png" /><figcaption>ML Kit Aktifleştirme</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*rzlS3HpUVxs2fZQRiWGsmw.png" /><figcaption>Auth Service Aktifleştirme</figcaption></figure><p><strong>4.</strong> Cloud Storage Kullanmak için ise aşağıdaki adımları gerçekleştirmemiz gerekiyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*BsUUBdAckS5rKnzSqfdQbg.png" /><figcaption>Cloud Storage Aktifleştirme</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*17iseRZX6R-ooMBQOjQSaA.png" /><figcaption>İstediğiniz instance belirleyebilirsiniz. Default location seçmelisiniz.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*7Dx_e2--vFsodf7gh12CJQ.png" /><figcaption>Finish diyerek işlem tamamlanmış olacaktır.</figcaption></figure><p><strong>5.</strong> Android Studio içerisinde AndroidManifest.xml dosyasına gerekle izinleri ekleyelim.</p><pre>&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt; <br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;<br>&lt;application<br>      android:allowBackup=&quot;false&quot;<br>      android:requestLegacyExternalStorage=&quot;true&quot;<br>.<br>.<br>. &lt;meta-data<br>android:name=&quot;com.huawei.hms.ml.DEPENDENCY&quot;<br>android:value=&quot;imgseg&quot; /&gt;<br>&lt;/application&gt;</pre><p><strong>6.</strong> Gerekli bağımlılıkları build.gradle içerisine ekleyelim.</p><pre> //Huawei Auth<br>    implementation &#39;com.huawei.agconnect:agconnect-auth:1.6.5.300&#39;<br>    //Ml Kit<br>    implementation &#39;com.huawei.hms:ml-computer-vision-segmentation:3.7.0.302&#39;<br>    // Import the multiclass segmentation model package.<br>    implementation &#39;com.huawei.hms:ml-computer-vision-image-segmentation-multiclass-model:3.7.0.302&#39;<br>    // Import the human body segmentation model package.<br>    implementation &#39;com.huawei.hms:ml-computer-vision-image-segmentation-body-model:3.7.0.302&#39;<br>    // Import the hair segmentation model package.<br>    implementation &#39;com.huawei.hms:ml-computer-vision-image-segmentation-hair-model:3.7.0.302&#39;<br>    //Cloud Storage<br>    implementation &quot;com.huawei.agconnect:agconnect-storage:1.5.0.100&quot;</pre><h3>Uygulama</h3><p>Şu ana kadar gerekli olan servisleri AppGallery Connect üzerinden aktifleştirdik ve gerekli bağımlılıkları projemize ekledik. Eğer herhangi bir hata ile karşılaştıysanız veya daha detaylı incelemek isterseniz makalenin sonundaki referanslar bölümünden ilgili kaynakları inceleyebilirsiniz.</p><h4>ML Kit Uygulanması</h4><pre>   var setting = MLImageSegmentationSetting.Factory()<br>            .setExact(true)<br>            .setAnalyzerType(MLImageSegmentationSetting.BODY_SEG)<br>            .setScene(MLImageSegmentationScene.FOREGROUND_ONLY)<br>            .create()<br>        analyzer = MLAnalyzerFactory.getInstance().getImageSegmentationAnalyzer(setting)<br>        val drawable: BitmapDrawable = binding.imageView.drawable as BitmapDrawable<br>        bitmap = drawable.bitmap<br>        val mlFrame = MLFrame.Creator().setBitmap(bitmap).create()<br>        val task: Task&lt;MLImageSegmentation&gt; = analyzer.asyncAnalyseFrame(mlFrame)<br>        task.addOnSuccessListener {<br>            removeBackGround(it)<br>        }.addOnFailureListener {<br>            Log.e(TAG1, &quot;analyse -&gt; asyncAnalyseFrame: &quot;, it)<br>        }</pre><p>Yukarıdaki kod satırları ile yeni bir segmentation oluşturuyoruz. Burada insan analizi yapacağımız ve sadece ön planın kalmasını istediğimiz içi analyzer tipini BOD_SEG ve setScene’i ise FOREGROUND_ONLY olarak ayarlıyoruz. Daha sonra bitmap ile fotoğrafımızı seçiyoruz ve task success olduğu zaman removeBackGround metodunu çalıştırıyoruz.</p><pre>private fun removeBackground(mlImageSegmentation: MLImageSegmentation?) {<br>        if (mlImageSegmentation != null) {<br>            if (bitmap == null) {<br>                Log.e(TAG1, &quot;bitmap is null&quot;)<br>                return<br>            }<br>            val bitmapFore: Bitmap = mlImageSegmentation.getForeground()<br>            if (bitmapFore != null) {<br>                binding.imageView.setImageBitmap(bitmapFore)<br>            } else {<br>                Log.e(TAG1, &quot;bitmap is null&quot;)<br>            }<br>        }<br>    }</pre><p>removeBackGround metodunun içinde bitmap ile gönderdiğimiz resmin arka planını MLImageSegmentation sınıfı ile siliyoruz.</p><h4>Auth Service Uygulanması</h4><p>Auth Service kullanmamızın amacı, Cloud Storage’ın bunu kullanırken bir authentication istemesidir.</p><pre>     if (AGConnectAuth.getInstance().currentUser != null) {<br>            DriverManager.println(&quot;already sign a user&quot;)<br>            Log.i(TAG2, &quot;already sign a user&quot;)<br>            return<br>        } else {<br>            AGConnectAuth.getInstance().signInAnonymously()<br>                .addOnSuccessListener {<br>                    DriverManager.println(&quot;AGConnect OnSuccess&quot;)<br>                    Log.i(TAG2, &quot;AGConnect OnSuccess&quot;)<br>                }<br>                .addOnFailureListener { e -&gt;<br>                    DriverManager.println(&quot;AGConnect OnFail: &quot; + e.message)<br>                    Log.i(TAG2, &quot;AGConnect OnFail ${e.message}&quot;)<br>                }<br>        }</pre><p>Yukarıdaki kod satırı ile anonymously (anonim) olarak giriş yapıyoruz ve Cloud Storage kullanabiliyoruz. İsterseniz gerçek kullanıcı girişi de yapabilirsiniz.</p><h4>Cloud Storage Uygulanması</h4><p>Öncelikle aşağıdaki kod ile yazma ve okuma izinlerini almamız gerekiyor.</p><pre>1. private val permissions = arrayOf&lt;String&gt;(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE)<br>2. ActivityCompat.requestPermissions(this, permissions, 1)</pre><p>Sonrasında Cloud Storage kullanabilmek için storage management ile instance almamız gerekiyor. Bu instance bizim Cloud ile bağlantımızı sağlayacaktır.</p><pre>private var mAGCStorageManagement: AGCStorageManagement? = null<br>val storageManagement = AGCStorageManagement.getInstance()<br>private fun initAGCStorageManagement() {<br>        mAGCStorageManagement = AGCStorageManagement.getInstance()<br>        Log.i(TAG2, &quot;Init AGC Storage Management success! &quot;)<br>    }</pre><h4>Cloud Storage Upload</h4><p>Aşağıdaki kod satırı ile fotoğrafımızı Cloud tarafına upload edebi liriz. Buradaki path cloud tarafındaki oluşturulacak dosyanın adıdır.</p><pre>val progressDialog = ProgressDialog(this)<br>        progressDialog.setMessage(&quot;Uploading File....&quot;)<br>        progressDialog.setCancelable(false)<br>        progressDialog.show()<br>        val systemCurrentTime: Long = System.currentTimeMillis()<br>        val path = &quot;/images/${systemCurrentTime}.png&quot;<br>        val agcSdkDirPath = agcSdkDirPath<br>        val file = File(agcSdkDirPath)<br>        if (!file.exists()) {<br>            Log.i(TAG2, &quot;file is not exist!&quot;)<br>            return<br>        } else {<br>            Log.i(TAG2, &quot;file is exist&quot;)<br>            val storageReference =<br>                mAGCStorageManagement!!.getStorageReference(path)<br>            val uploadTask = storageReference.putFile(file)<br><br>            uploadTask.addOnSuccessListener {<br>                Log.i(TAG2, &quot;upload success!&quot;)<br>                progressDialog.dismiss()<br>            }<br>                .addOnFailureListener { e: Exception -&gt;<br>                    progressDialog.dismiss()<br>                    Log.i(<br>                        TAG2,<br>                        &quot;Upload Failed $e&quot;<br>                    )<br>                }<br>        }<br>private val agcSdkDirPath: String<br>        get() {<br>            DriverManager.println(&quot;path=$path&quot;)<br>            val dir = File(path)<br>            if (!dir.exists()) {<br>                dir.mkdirs()<br>            }<br>            return path!!<br>        }</pre><h4>Cloud Storage Listeleme</h4><p>Aşağıdaki kod satırları ile images/ klasörüne upload yaptığımız dosyaları görüntüleyebiliriz ve liste üzerinde gösterebiliriz.</p><pre>val path = &quot;images/&quot;<br>        val storageReference = mAGCStorageManagement?.getStorageReference(path)<br>        var listResultTask: Task&lt;ListResult&gt;? = null<br>        listResultTask = storageReference?.list(100)<br>        listResultTask?.addOnSuccessListener {<br>            fileList = ArrayList(it.fileList)<br>            mAdapter = DownloadListAdapter(<br>                this@DownloadListActivity,<br>                fileList = fileList,<br>                mAGCStorageManagement,<br>                this@DownloadListActivity<br>            )<br>            binding.recyclerView.adapter = mAdapter<br>            mAdapter.notifyDataSetChanged()<br><br>            Log.i(&quot;MYSTORAGE&quot;, &quot;SUCCEDD: ${fileList.size}&quot;)<br>        }?.addOnFailureListener {<br>            Log.e(&quot;MYSTORAGE&quot;, &quot;FAIL: ${it.printStackTrace()}&quot;)<br>        }<br>    }</pre><h4>Cloud Storage İndirme</h4><p>Cloud üzerinden herhangi bir dosyamızı indirmek istediğimizde o dosyanın yolunu ve adını doğru tanımlamamız gerekiyor bunun için File metoduna agcSdkDirPath ve fileName parametrelerini tanımladım ve storageReference.getFile(file) ile dosya indirme isteği gönderiyorum.</p><pre>     val progressDialog = ProgressDialog(context)<br>        progressDialog.setMessage(&quot;Downloading File....&quot;)<br>        progressDialog.setCancelable(false)<br>        progressDialog.show()<br>        val fileName = fileName<br>        val path = path<br>        val agcSdkDirPath = agcSdkDirPath2<br>        val file = File(agcSdkDirPath, fileName)<br>        val storageReference = mAGCStorageManagement!!.getStorageReference(path)<br>        val downloadTask = storageReference.getFile(file)<br>        downloadTask.addOnSuccessListener {<br>            Toast.makeText(context, &quot;Download Succeed&quot;, Toast.LENGTH_SHORT).show()<br>            progressDialog.dismiss()<br>        }.addOnFailureListener { e: Exception -&gt;<br>            Toast.makeText(context, &quot;Download Error&quot;, Toast.LENGTH_SHORT).show()<br>            progressDialog.dismiss()<br>            Log.i(&quot;MYSTORAGE&quot;, &quot;DOWNLOAD ERROR: $e&quot;)<br>        }<br>private val agcSdkDirPath2: String<br>        get() {<br>            val path =<br>                Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).absoluteFile.toString()<br>            DriverManager.println(&quot;path=$path&quot;)<br>            val dir = File(path)<br>            if (!dir.exists()) {<br>                dir.mkdirs()<br>            }<br>            return path<br>        }</pre><h4>Cloud Storage Silme</h4><p>Dosya indirmede olduğu gibi path doğru verilmeli ve storageReference.delete() metodu çağırılmalı.</p><pre>val path = path<br>        DriverManager.println(&quot;path=%s$path&quot;)<br>        val storageReference = mAGCStorageManagement!!.getStorageReference(path)<br>        val deleteTask = storageReference.delete()<br>        deleteTask.addOnSuccessListener {<br>            Toast.makeText(context, &quot;Delete Succeed&quot;, Toast.LENGTH_SHORT).show()<br>            activity.getAllList()<br>            notifyDataSetChanged()<br><br>        }<br>            .addOnFailureListener { e: Exception -&gt;<br>                Toast.makeText(context, &quot;Delete Error:&quot;, Toast.LENGTH_SHORT).show()<br>                Log.i(&quot;MYSTORAGE&quot;, &quot;DELETE ERROR: $e&quot;)<br>            }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wnIl7VynOwkxaUnXwrcVkw.png" /><figcaption>Ekran Görüntüleri</figcaption></figure><h3>Sonuç</h3><p>Bu makalede, ML Kiti kullanarak fotoğrafların arka planını sildik. Cloud Storage kullanarak arka planını sildiğimiz fotoğraları Cloud tarafına yükledik, fotoğraflarımızı listeleme ve silme işlemlerini gerçekleştirdik. Umarım sizler için faydalı bir makale olmuştur.</p><h3>Referanslar</h3><ul><li><a href="https://github.com/huaweicodelabs/multi-kit-codelabs/tree/main/ImageBGCleaner">multi-kit-codelabs/ImageBGCleaner at main · huaweicodelabs/multi-kit-codelabs</a></li><li><a href="https://developer.huawei.com/consumer/en/hms/huawei-mlkit/">ML Kit - Machine Learning Service - HUAWEI Developer</a></li><li><a href="https://developer.huawei.com/consumer/en/agconnect/auth-service/">Auth Service - HUAWEI Developers</a></li><li><a href="https://developer.huawei.com/consumer/en/agconnect/cloud-storage/">Cloud Storage - HUAWEI Developers</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=103493125cb2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers-tr/hms-kullanarak-resimlerinizi-d%C3%BCzenleyin-ml-kit-cloud-storage-auth-service-android-kotlin-103493125cb2">HMS Kullanarak Resimlerinizi Düzenleyin (ML Kit, Cloud Storage, Auth Service) Android - Kotlin</a> was originally published in <a href="https://medium.com/huawei-developers-tr">Huawei Developers - Türkiye</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[‍What is Huawei Cloud Storage and How to Use it ? Android | Kotlin]]></title>
            <link>https://medium.com/huawei-developers/what-is-huawei-cloud-storage-and-how-to-use-it-android-kotlin-52ed7be5548a?source=rss-d31aaf4017d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/52ed7be5548a</guid>
            <category><![CDATA[huawei-cloud-storage]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[cloud-storage]]></category>
            <category><![CDATA[huawei-mobile-service]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Sezer Özaltun]]></dc:creator>
            <pubDate>Mon, 05 Dec 2022 06:48:45 GMT</pubDate>
            <atom:updated>2022-12-05T06:48:45.620Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://medium.com/huawei-developers/kotlin-abstraction-and-abstract-class-7c04085396e2?source=collection_detail----25443cf6c73-----1-----------------------">👨🏼‍💻</a>What is Huawei Cloud Storage and How to use it ? Android | Kotlin</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cPa-ESAleFe1Ayqb3wO7ew.png" /><figcaption>Huawei Cloud Storage</figcaption></figure><h3>Introduction</h3><p>Hello everyone, we are together with a new article. I’ll explain some topics such as What is Cloud Storage and How Can we use it. Let’s start.</p><h3>What is Cloud Storage ?</h3><p>AppGallery Connect Cloud Storage allows you to store high volumes of data such as images, audio, videos, and other user-generated content securely and economically.</p><h3>Advantages of Cloud Storage</h3><ul><li><strong>Strong security: </strong>Data is transmitted using HTTPS, and files are encrypted and stored on the cloud using secure encryption protocols.</li><li><strong>Resumable transfer:</strong> You can resume uploads or downloads from the breakpoint if there is a network failure or misoperation while the upload or download is underway.</li><li><strong>High scalability:</strong> Cloud Storage is built for exabyte scale when your app has much data to store.</li><li><strong>Easy O&amp;M:</strong> You can easily locate the cause of an error according to the result code.</li></ul><h3>How To Use Cloud Storage</h3><p>Now let’s see how to use Cloud Storage step by step.</p><h4>Enabling the Service</h4><ol><li>Sign in to <a href="https://developer.huawei.com/consumer/en/service/josp/agc/index.html">AppGallery Connect</a> and click <strong>My projects</strong>.</li><li>Find and click your project.</li><li>Go to <strong>Build</strong> &gt; <strong>Cloud Storage</strong>. On the <strong>Cloud Storage</strong> page, click <strong>Enable now</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OKmISGbJG5BK9775" /><figcaption>Cloud Storage Enable now</figcaption></figure><p>4. On the page displayed, set <strong>Storage instance</strong> and <strong>Default data processing location</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*utqDYuEweTuoZtWa" /><figcaption>Cloud Storage Reference</figcaption></figure><blockquote><strong>Note: </strong>If you select Germany as location, you need to send mail to get permisson. Recommended Singapore</blockquote><p>5. Click <strong>Next</strong> and view the default security rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*_J3VRlOKIIgTZEfP" /><figcaption>Security Rules</figcaption></figure><blockquote><strong>Note:</strong> The default security rules allow authorized users to read and write all files. You can modify <a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-cloudstorage-securityrules-overview-0000001054966859">rules</a> only after the service is enabled.</blockquote><p>6. Click <strong>Finish</strong>.</p><h4>AppGallery Connect Configuration</h4><p>For its configuration for AppGallery Connect, you can read the related article by clicking <a href="https://medium.com/huawei-developers/android-integrating-your-apps-with-huawei-hms-core-1f1e2a090e98">here</a>.</p><h4>Integrating Cloud Storage SDK</h4><ol><li><a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-storage-obtain-files-0000001275499192#section11351329162211">Obtain the agconnect-services.json file</a>.</li><li>Verify the <strong>default_storage</strong> setting under <strong>service &gt; cloudstorage</strong> in the <strong>agconnect-services.json</strong> file</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9b642eb45797ca8a0e0ce6c4b6109bb/href">https://medium.com/media/b9b642eb45797ca8a0e0ce6c4b6109bb/href</a></iframe><p>3. Configure a dependency on Cloud Storage to the <strong>dependencies</strong> block in build gradle(app)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f23a52cfef8702918519f126fb3fa1a6/href">https://medium.com/media/f23a52cfef8702918519f126fb3fa1a6/href</a></iframe><h4>Modifying the AndroidManifest File</h4><p>To read and write files and access the Internet, configure the following permissions in the <strong>AndroidManifest.xml</strong> file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf9a55e8d50ccf7355d9a088708a7a17/href">https://medium.com/media/cf9a55e8d50ccf7355d9a088708a7a17/href</a></iframe><h4>Initializing Permissions</h4><p>To enable the Cloud Storage SDK to obtain the device storage permission, call the permission request methods in the <strong>onCreate</strong> method of <strong>MainActivity</strong>. The sample code is as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b405ec125a51e891c10646bb5738bf2/href">https://medium.com/media/8b405ec125a51e891c10646bb5738bf2/href</a></iframe><h4>Initializing a Storage Instance</h4><p>You can initialize an instance by adding the following codes to your project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22d5b60aef73ef97c3d7123c8a1a1075/href">https://medium.com/media/22d5b60aef73ef97c3d7123c8a1a1075/href</a></iframe><h4>Creating a Reference</h4><p>Files are stored in storage instances on the cloud. The files in a storage instance are presented in a hierarchical structure, just like the file system on your local hard disk. After creating a reference to a file, you can use this reference to upload, download, or delete the file, or update its metadata. In addition, you can also create a reference to a directory and use this reference to list all files in this directory. We will do this during the file upload.</p><h4>Uploading a File</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92607b0748ee980f0a68052ac1f4d6dc/href">https://medium.com/media/92607b0748ee980f0a68052ac1f4d6dc/href</a></iframe><p>You can upload files using the code here. I uploaded it with a .png extension because I wanted upload image.</p><p><strong>path: </strong>Your file path on Cloud Storage.</p><p><strong>agcSdkDirPath: </strong>It allows you to get the path of your file in the phone’s memory.</p><p><strong>File: </strong>storageReference expects a file path of type File from us. So we define agcSdkDirPath in File.</p><h4>Listing Files</h4><p>You can use the code below to view all the files you have uploaded to Cloud Storage.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7aa4ecd4862fe9443a5d537302889b6e/href">https://medium.com/media/7aa4ecd4862fe9443a5d537302889b6e/href</a></iframe><p><strong>path: </strong>It is the address of the files you upload on Cloud Storage.</p><p>listResultTask returns a list of type Listresult. I converted it to ArrayList and showed the whole list in RecyclerView.</p><h4>Downloading a File</h4><p>You can safely download files on Cloud Storage with the code below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ca904786577f4232dc2b153ed7b36be/href">https://medium.com/media/1ca904786577f4232dc2b153ed7b36be/href</a></iframe><p>I used the Environment.DIRECTORY_DOWNLOADS parameter because I prefer that the pictures in Cloud Storage are downloaded to the downloads folder of the phone.</p><h4>Deleting a File</h4><p>You can delete your file on Cloud Storage with the code below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0dc4f3898cbdeb3eb8b0671f44725933/href">https://medium.com/media/0dc4f3898cbdeb3eb8b0671f44725933/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*MlGW7A3tx1PbMggH.png" /><figcaption>Cloud Storage File Path</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ym-g0lHUpXm6uEpJ.png" /><figcaption>Cloud Storage Uploaded Files</figcaption></figure><h3>Conclusion</h3><p>In this article, we learned what Cloud Storage is and how to use it. With Cloud Storage, you can securely and easily store your files on the cloud and access them from anywhere. I hope it has been a useful resource for you. See you in the next articles….</p><h3>References</h3><p><a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-cloudstorage-view-0000001274972232">Document</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52ed7be5548a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/what-is-huawei-cloud-storage-and-how-to-use-it-android-kotlin-52ed7be5548a">👨🏼‍💻What is Huawei Cloud Storage and How to Use it ? Android | Kotlin</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Huawei Cloud Storage Nedir? Nasıl Kullanılır ? Android | Kotlin]]></title>
            <link>https://medium.com/huawei-developers-tr/huawei-cloud-storage-nedir-nas%C4%B1l-kullan%C4%B1l%C4%B1r-android-kotlin-f327383f5fdc?source=rss-d31aaf4017d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f327383f5fdc</guid>
            <category><![CDATA[cloud-storage]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[huawei-cloud-storage]]></category>
            <category><![CDATA[huawei-mobile-service]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Sezer Özaltun]]></dc:creator>
            <pubDate>Fri, 02 Dec 2022 12:27:16 GMT</pubDate>
            <atom:updated>2022-12-02T12:27:16.840Z</atom:updated>
            <content:encoded><![CDATA[<h3>Huawei Cloud Storage Nedir? Nasıl Kullanılır ? Android | Kotlin</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cPa-ESAleFe1Ayqb3wO7ew.png" /><figcaption>Huawei Cloud Storage</figcaption></figure><h3>Giriş</h3><p>Herkese merhabalar, yeni bir makale ile birlikteyiz. Bu makalede Huawei Cloud Storage nedir ve nasıl kullanılır konularını anlatacağım.Hadi başlayalım.</p><h3>Cloud Storage Nedir ?</h3><p>Huawei Cloud Storage, dosyalarınızı, resimlerinizi, müziklerinizi, ve videolar gibi büyük ölçekli verilerinizi güvenli ve ekonomik bir şekilde online olarak bulutta depolamanıza olanak sağlar.</p><h3>Cloud Storage Avantajları</h3><ul><li><strong>Güçlü güvenlik </strong>: Veriler HTTPS kullanılarak iletilir ve dosyalar güvenli şifreleme protokolleri kullanılarak şifrelenir ve bulutta depolanır.</li><li><strong>Sürdürülebilir aktarım:</strong> Karşıya yükleme veya indirme işlemi devam ederken bir ağ arızası veya yanlış çalışma olursa, yükleme veya indirme işlemlerini kaldığı yerden devam ettirebilirsiniz.</li><li><strong>Yüksek ölçeklenebilirlik: </strong>Cloud Storage, uygulamanızın depolayacak çok fazla verisi olduğunda exabyte ölçeği için tasarlanmıştır.</li><li><strong>Kolay İşletme ve Bakım:</strong> Sonuç koduna(Result codes) göre bir hatanın nedenini kolayca bulabilirsiniz.</li></ul><h3>Cloud Storage Nasıl Kullanılır ?</h3><p>Şimdi de adım adım Cloud Storage’i nasıl kullanacağımı görelim.</p><h4><strong>Servisi Etkinleştirme</strong></h4><ol><li><a href="https://developer.huawei.com/consumer/en/service/josp/agc/handleAllianceLogin.html?_=20221019180832">AppGallery Connect</a>’te oturum açın ve My Projects sekmesine tıklayın.</li><li>Açılan pencerede projenizi bulun ve tıklayın.</li><li>Daha sonra Build -&gt; Cloud Storage sekmesine tıklayarak açılan sayfada Enable now butonuna tıklayın.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OKmISGbJG5BK9775" /><figcaption>Cloud Storage Enable now</figcaption></figure><p>4. Açılan yeni ekranda Storage instance alanına istediğiniz ismi verebilirsiniz. Default data proccessing location alanında ise açılan pencerede var olan konumlardan birini seçebilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*utqDYuEweTuoZtWa" /><figcaption>Cloud Storage Reference</figcaption></figure><blockquote><strong><em>Not:</em></strong><em> Location’da Almanya’yı seçerseniz izin almak için mail göndermeniz gerekiyor. Singapur seçmeniz önerilir.</em></blockquote><p>5. Next butonuna tıklayarak güvenlik kurallarını belirleyebilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*_J3VRlOKIIgTZEfP" /><figcaption>Security Rules</figcaption></figure><blockquote><strong>Not:</strong> Varsayılan güvenlik kuralları, yetkili kullanıcıların tüm dosyaları okumasına ve yazmasına izin verir. Kuralları yalnızca hizmet etkinleştirildikten sonra değiştirebilirsiniz.</blockquote><p>6. Finish butonuna tılayarak işlemi tamamlayın.</p><h4>AppGallery Connect Yapılandırması</h4><p>AppGallery Connect için yapılandırması için <a href="https://medium.com/huawei-developers-tr/android-uygulamalar%C4%B1n%C4%B1za-huawei-hms-core-entegre-edin-542476f58910">buraya </a>tıklayarak ilgili makaleyi okuyabilirsiniz.</p><h4>Cloud Storage SDK’sını Projeye Ekleme</h4><ol><li>Öncelikle <a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-storage-obtain-files-0000001275499192#section11351329162211">agconnect-services-json </a>dosyasını projenize dahil ettiğinizden emin olun.</li><li>Sonrasında aşağıdaki kodların agconnect-services-json dosyası içerisinde yer aldığını doğrulayın.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9b642eb45797ca8a0e0ce6c4b6109bb/href">https://medium.com/media/b9b642eb45797ca8a0e0ce6c4b6109bb/href</a></iframe><p>3. build gradle(app) içerisine aşağıdaki bağımlılığı ekleyin.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f23a52cfef8702918519f126fb3fa1a6/href">https://medium.com/media/f23a52cfef8702918519f126fb3fa1a6/href</a></iframe><h4>Android Manifest Düzenlemeleri</h4><p>Aşağıdaki kodlar eklemeniz gerekiyor</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf9a55e8d50ccf7355d9a088708a7a17/href">https://medium.com/media/cf9a55e8d50ccf7355d9a088708a7a17/href</a></iframe><h4>Gerekli izinleri Almak</h4><p>Cloud Storage kullanmadan önce gerekli izinleri almamız gerekiyor.Aşağıdaki kodları ilgili alana ekleyin.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b405ec125a51e891c10646bb5738bf2/href">https://medium.com/media/8b405ec125a51e891c10646bb5738bf2/href</a></iframe><h4>Storage Instance Başlatmak</h4><p>Aşağıdaki kodları projenize ekleyerek instance başlatabilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22d5b60aef73ef97c3d7123c8a1a1075/href">https://medium.com/media/22d5b60aef73ef97c3d7123c8a1a1075/href</a></iframe><h4>Reference Oluşturma</h4><p>Dosyalar, bulut üzerindeki depolama örneklerinde depolanır. Bir depolama örneğindeki dosyalar, tıpkı yerel sabit diskinizdeki dosya sistemi gibi hiyerarşik bir yapıda sunulur. Bir dosyaya referans oluşturduktan sonra, bu referansı dosyayı yüklemek, indirmek veya silmek ya da meta verilerini güncellemek için kullanabilirsiniz. Ek olarak, bir dizine bir referans oluşturabilir ve bu referansı bu dizindeki tüm dosyaları listelemek için kullanabilirsiniz. Bu işlemi Dosya yükleme sırasında gerçekleştireceğiz.</p><h4>Dosya Yükleme</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92607b0748ee980f0a68052ac1f4d6dc/href">https://medium.com/media/92607b0748ee980f0a68052ac1f4d6dc/href</a></iframe><p>Buradaki kod sayesinde karşıya dosya yükleyebilirsiniz. Ben resim yüklediğim için .png uzantılı yükledim.</p><p><strong>path:</strong> Cloud Storage üzerindeki dosya yolunuz.</p><p><strong>agcSdkDirPath:</strong> Telefonun hafızasındaki dosyanızın yolunu almanızı sağlıyor.</p><p><strong>File:</strong> storageReference bizden File tipinde dosya yolu bekliyor. Bu yüzden File içine agcSdkDirPath tanımlıyoruz.</p><h4>Dosya Listeleme</h4><p>Cloud Storage’e yüklediğiniz tüm dosyaları görüntülemek için aşağıdaki kodu kullanabilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7aa4ecd4862fe9443a5d537302889b6e/href">https://medium.com/media/7aa4ecd4862fe9443a5d537302889b6e/href</a></iframe><p><strong>path:</strong> Cloud Storage üzerinde yüklediğiniz dosyaların adresidir.</p><p>listResultTask, Listresult türünde bir liste döndürüyor. Bunu ArrayList’e dönüştürerek RecyclerView içerisinde tüm listeyi gösterdim.</p><h4>Dosya İndirme</h4><p>Aşağıdaki kod ile Cloud Storage üzerindeki dosyalarını güvenli bir şekilde indirebilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ca904786577f4232dc2b153ed7b36be/href">https://medium.com/media/1ca904786577f4232dc2b153ed7b36be/href</a></iframe><p>Ben Cloud Storage’de yer alan resimleri telefonun indirilenler klasörüne indirmesini tercih ettiğim için Environmen.DIRECTORY_DOWNLOADS parametresini kullandım.</p><h4>Dosya Silme</h4><p>Aşağıdaki kod ile Cloud Storage üzerindeki yer alan dosyanızı silebilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0dc4f3898cbdeb3eb8b0671f44725933/href">https://medium.com/media/0dc4f3898cbdeb3eb8b0671f44725933/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kK-JMHZxi2U1O8fl9y-EwA.png" /><figcaption>Cloud Storage Dosya Yolu</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AhOVH6Uj3lwXjPg1aEdoqQ.png" /><figcaption>Cloud Storage Yüklenen Dosyalar</figcaption></figure><h3>Sonuç</h3><p>Bu makalede, Cloud Storage’ın ne olduğunu ve nasıl kullanıldığını öğrendik. Cloud Storage ile dosyalarınızı güvenli ve kolay bir şekilde bulut üzerinde depolayabilir ve her yerden erişebilirsiniz. Umarım sizler için faydalı bir kaynak olmuştur. Sonraki makalelerde görüşmek üzere….</p><h3>Referanslar</h3><p><a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-cloudstorage-view-0000001274972232">Document</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f327383f5fdc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers-tr/huawei-cloud-storage-nedir-nas%C4%B1l-kullan%C4%B1l%C4%B1r-android-kotlin-f327383f5fdc">Huawei Cloud Storage Nedir? Nasıl Kullanılır ? Android | Kotlin</a> was originally published in <a href="https://medium.com/huawei-developers-tr">Huawei Developers - Türkiye</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[‍ViewBinding vs DataBinding | Differences and Detailed]]></title>
            <link>https://medium.com/huawei-developers/viewbinding-vs-databinding-differences-and-detailed-8bfd4dbe290f?source=rss-d31aaf4017d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bfd4dbe290f</guid>
            <category><![CDATA[data-binding]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[view-binding]]></category>
            <dc:creator><![CDATA[Sezer Özaltun]]></dc:creator>
            <pubDate>Thu, 17 Nov 2022 18:55:02 GMT</pubDate>
            <atom:updated>2022-11-18T05:24:34.743Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*CDlS_reOGVgZgWGo.jpeg" /><figcaption>ViewBinding vs DataBinding</figcaption></figure><h3>Introduction</h3><p>Hello everyone,</p><p>We are together with a new medium article. In this article, What are View Binding and Data Binding that we use a lot in our Android projects?, Why do we use them?, and when should we use it? We’ll talk about things like these.</p><p>As you know, some projects use View Binding while others use Data Binding. So why do we choose to use them? Why do some android developers use View Binding and others use Data Binding? If you are looking for answers to questions like these, you are in the right here:)</p><h3>What is View Binding ?</h3><p>View Binding makes it easier and faster to bind your code to the relevant layout xml file. We would use findViewById to do this. We needed to define as many objects as the number of objects in our xml layout. Thanks to View Binding, we only need to define it once. That’s enough. After binding once using View Binding, we can create a variable and then we can access all objects in the layout xml using this variable.</p><h3>View Binding vs findViewById</h3><p>There are two fundamental differences.</p><ul><li><strong>Faster Compilation: </strong>View Binding does not require annotation, so compile time is faster.</li><li><strong>Ease to Use: </strong>View Binding does not require us to define specially labeled layout xml files. We do not need to define separately for each widget. We define it only 1 time and it is created automatically. Therefore, it is faster to use.</li></ul><h3>How to use (Activity) ?</h3><p><strong>1-</strong> First we need to add the View Binding library into the build gradle(app).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9d38bedb6397b0f7da393e0d8050e2f/href">https://medium.com/media/b9d38bedb6397b0f7da393e0d8050e2f/href</a></iframe><p><strong>2-</strong> After adding it, let’s write the following codes in the Activity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1bfedac9f054d5b8922c5b64f8e8f2db/href">https://medium.com/media/1bfedac9f054d5b8922c5b64f8e8f2db/href</a></iframe><p><strong>3-</strong> That’s all. After that, you can access the widget you want using the binding variable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de32e94c44db588d25ccf6cc51d3ff4b/href">https://medium.com/media/de32e94c44db588d25ccf6cc51d3ff4b/href</a></iframe><h3>How to use (Fragment) ?</h3><p>1- Let’s add the library to the build gradle(app) as we did in the use of Activity.</p><p>2- After writing the following codes in the fragment, you can access all the objects in the layout xml with the binding object.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4201fcf804cd285a3493046aca0f14cd/href">https://medium.com/media/4201fcf804cd285a3493046aca0f14cd/href</a></iframe><h3>What is Data Binding ?</h3><p>Data Binding is the process of binding data to layout xml file. It allows you to keep your data and view it in sync. Data Binding can be one-way or two-way.</p><p><strong>One-way: </strong>Changes in data are not reflected in the view.</p><p><strong>Two-way: </strong>Changes in data are reflected in the view</p><p>With Data Binding, our design and code page are completely separated. We can even be more independent from the Activity by writing some functions in our layout xml. Thanks to the Binding Adapter, we can create custom functions.</p><h3>How to use (Activity) ?</h3><p><strong>1-</strong> First we need to add the View Binding library into the build gradle(app).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1bb60298eb015d64f16e4fb525d3f4b9/href">https://medium.com/media/1bb60298eb015d64f16e4fb525d3f4b9/href</a></iframe><p><strong>2-</strong> Let’s edit our layout xml file as follows. We just need to add the &lt;layout&gt; tag. I’ll explain the &lt;data&gt; part shortly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19a55d6210791589245170989eeef7bd/href">https://medium.com/media/19a55d6210791589245170989eeef7bd/href</a></iframe><p><strong>3-</strong> After writing the following codes in the Activity, we can access all the objects in the layout xml using the binding variable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/359b65ab85a192c10c68f5bbb938ba11/href">https://medium.com/media/359b65ab85a192c10c68f5bbb938ba11/href</a></iframe><h3>How to use (Fragment) ?</h3><p><strong>1- </strong>Let’s add the library to the build gradle(app) as we did in the use of Activity.</p><p><strong>2-</strong> Let’s edit our Layout xml file as follows. This time we fill in the &lt;data&gt; section. You can do the same process for Activity. I preferred to do it using Fragment.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de5686ee5f1f4fb68c713d605dc9a193/href">https://medium.com/media/de5686ee5f1f4fb68c713d605dc9a193/href</a></iframe><p>Here, I can send data to design objects through the model in &lt;data&gt;. Thanks to the Binding Adapter, I can easily display images in ImageView.</p><p><strong>3-</strong> Let’s create the Model Class. We will fetch the data from this class and display the data on the layout using Data Binding.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c80f2cf422ffd31c812b33f53429c3f9/href">https://medium.com/media/c80f2cf422ffd31c812b33f53429c3f9/href</a></iframe><p><strong>4-</strong> Let’s create Binding Adapter to show image in ImageView.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/776b1ea3a9025e5300aa46491f02e898/href">https://medium.com/media/776b1ea3a9025e5300aa46491f02e898/href</a></iframe><p><strong>5-</strong> We connect our row_item.xml file to the HomeAdapter class using Data Binding and here we send our data to our layout xml file using the binding.model = item code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/060e0458963053c4e8915b579af963e1/href">https://medium.com/media/060e0458963053c4e8915b579af963e1/href</a></iframe><p><strong>6-</strong> As the last step, let’s write the necessary Data Binding codes in the Fragment. In order to see the data on the screen, we need to connect the HomeAdapter and the Fragment. Since our topic is Data Binding, I did not add those codes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ff241904be3b9ba1ceedeee87b5b423/href">https://medium.com/media/7ff241904be3b9ba1ceedeee87b5b423/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*9auyPu76l9tDJdfv.png" /><figcaption>Data Binding vs View Binding</figcaption></figure><h3>View Binding vs Data Binding</h3><ul><li>View Binding is a way to bind your code to specific layout xml files. This allows you to access and modify view properties directly from your code.</li><li>Data Binding is a way to bind data to layout xml files. This allows you to bind data directly to your views without writing extra code.</li><li>As you can see in the image below, Data Binding encompasses everything View Binding does. In terms of binding schemes, both are the same. Data Binding also allows us to use variables from the XML file. So which one should we use?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*m7gQ7cVcfHV4H2AB.png" /><figcaption>View Binding vs Data Binding</figcaption></figure><h3>Which Should I Use?</h3><ul><li>This depends on your needs.</li><li>View Binding is a good choice for accessing only the objects in your layout file.</li><li>Data Binding is a better choice if you need to send data to your objects in the Layout.</li><li>If you are using MVVM in your project, it would be better to use Data Binding.</li><li>Since we can also transfer data to the view with Data Binding, it will be more compatible with MVVM and clean code structure.</li></ul><blockquote>Data Binding and View Binding can be used together in our project. We can use Data Binding in views to which we transfer data, and View Binding in views that we do not transfer.</blockquote><h3>When should I use which one?</h3><p>If you are developing a UI in your Android project, you have two options for accessing the objects in the layout. These are View Binding and Data Binding. Both have pros and cons, so it’s important to know when to use each.</p><ul><li>View Binding is suitable for simple UIs with a few views. Installation is quick and easy. However, it may be less secure than Data Binding because it cannot check for errors at compile time.</li><li>Data Binding is more powerful than View Binding and it can be used for more complex layouts. It is also more reliable because it checks for errors at compile time.</li></ul><h3>Conclusion</h3><p>Both View Binding and Data Binding have their own advantages and disadvantages, so which one you should choose depends on your needs. If you want to have a more organized code and you have a project that you want to transfer data from to layot xml file , you can use Data Binding. If you want to access Layout files faster and easier, but do not want to transfer data, you can use View Binding.</p><p>We have come to the end of another article. I hope it was a useful article for you. See you in the next article. Take care of yourselves.</p><h3>References</h3><ul><li><a href="https://developer.android.com/topic/libraries/view-binding">View binding | App architecture | Android Developers</a></li><li><a href="https://developer.android.com/topic/libraries/data-binding">Data Binding Library | Android Developers</a></li><li><a href="https://github.com/sezer1578/MVVMHiltDemoProject">GitHub - sezer1578/MVVMHiltDemoProject: This demo is developed using MVVM , Hilt and Room Database</a></li><li><a href="https://github.com/sezer1578/PagingSampleProject">GitHub - sezer1578/PagingSampleProject: Paging Sample</a></li><li><a href="https://stackoverflow.com/questions/58040778/android-difference-between-databinding-and-viewbinding">Android : Difference between DataBinding and ViewBinding</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bfd4dbe290f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/viewbinding-vs-databinding-differences-and-detailed-8bfd4dbe290f">👨🏼‍💻ViewBinding vs DataBinding | Differences and Detailed</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nedir Bu DataBinding ve ViewBinding? Farkları ve Detaylı Anlatım]]></title>
            <link>https://medium.com/huawei-developers-tr/nedir-bu-databinding-ve-viewbinding-farklar%C4%B1-ve-detayl%C4%B1-anlat%C4%B1m-c99ff7b01e8a?source=rss-d31aaf4017d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c99ff7b01e8a</guid>
            <category><![CDATA[data-binding]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[view-binding]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Sezer Özaltun]]></dc:creator>
            <pubDate>Thu, 03 Nov 2022 15:50:04 GMT</pubDate>
            <atom:updated>2022-11-03T15:50:04.119Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2IQUhuCYiZujW430Z9BoIw.jpeg" /><figcaption>ViewBinding vs DataBinding</figcaption></figure><h3>Giriş</h3><p>Herkese merhabalar,</p><p>Yeni bir medium yazısı ile birlikteyiz. Bu makalede, Android projelerimizde oldukça çok kullandığımız View Binding ve Data Binding nedir? , neden bunları kullanırız? ve ne zaman kullanmalıyız? gibi konulara değineceğiz.</p><p>Sizlerde farketmişsinizdir, bazı projelerde View Binding kullanılıyorken diğerlerinde ise Data Binding kullanılıyor. Peki neden bunları kullanmayı tercih ediyoruz? Neden biri View Binding kullanırken diğeri Data Binding kullanıyor? Bunun gibi sorulara cevap arıyorsanız doğru yerdesiniz :)</p><h3>View Binding Nedir?</h3><p>View Binding, kodunuzu ilgili layout xml dosyasına daha kolay ve daha hızlı olarak bağlamanızı sağlar. Bunu yapmak için önceden findViewById kullanırdık ve layout xml dosyamızda kaç tane nesne varsa o kadar tanımlama yapmamız gerekiyordu. ViewBinding sayesinde bunu sadece 1 kez tanımlamamız yeterli oluyor. View Binding ile 1 kez bağladıktan sonra bir değişken oluşturup ardından bu oluştuduğumuz değişken ile layout xml içerisindeki tüm nesnelere erişebiliriz.</p><h3>View Binding ve findViewById Farkları</h3><p>İki tane temel farklı vardır.</p><ul><li><strong>Daha Hızlı Derleme: </strong>View Binding annotation(açıklama) gerektirmez, bu nedenle derleme süresi daha hızlıdır.</li><li><strong>Kullanım Kolaylığı: </strong>View Binding ile özel olarak etiketlenmiş layout xml dosyaları tanımlamamızı gerektirmez.Her widget için ayrı ayrı tanımlama yapmamıza gerek yoktur. Sadece 1 kez tanımlarız ve otomatik olarak oluşturulur. Bu nedenle kullanımı daha hızlıdır.</li></ul><h3>Nasıl Kullanılır (Activity) ?</h3><p><strong>1-</strong> Öncelikle View Binding kütüphanesini build gradle(app) içine eklemeliyiz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9d38bedb6397b0f7da393e0d8050e2f/href">https://medium.com/media/b9d38bedb6397b0f7da393e0d8050e2f/href</a></iframe><p><strong>2-</strong> Ekledikten sonra Activity içerisine aşağıdaki kodları yazalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1bfedac9f054d5b8922c5b64f8e8f2db/href">https://medium.com/media/1bfedac9f054d5b8922c5b64f8e8f2db/href</a></iframe><p><strong>3-</strong> Bu kadar. Bundan sonra istediğiniz widget’a binding değişkeni ile erişebilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de32e94c44db588d25ccf6cc51d3ff4b/href">https://medium.com/media/de32e94c44db588d25ccf6cc51d3ff4b/href</a></iframe><h3>Nasıl Kullanılır (Fragment) ?</h3><p>1- Activity kullanımında yaptığımız gibi build gradle(app) içine kütüphaneyi ekleyelim.</p><p>2- Fragment içine aşağıdaki kodları yazdıktan sonra binding nesnesi ile layout xml içerisindeki tüm nesnelere erişebilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4201fcf804cd285a3493046aca0f14cd/href">https://medium.com/media/4201fcf804cd285a3493046aca0f14cd/href</a></iframe><h3>Data Binding Nedir ?</h3><p>Data Binding, verileri bir layout xml dosyasına bağlama işlemidir. Bu, verilerinizi tumanıza ve senkronize halde görüntülemenize olanak tanır.Data Binding, iki yönlü veya tek yönlü olabilir.</p><ul><li><strong>İki Yönlü:</strong> Verilerdeki değişiklikler görünüme yansıtılır</li><li><strong>Tek Yönlü:</strong> Verilerdeki değişiklikler görünüme yansıtılmaz.</li></ul><p>Data Binding ile tasarım ve kod sayfamız tamamen birbirinden ayrılır. Hatta tasarım sayfamızda(layout xml) bazı fonksiyonlar yazarak Activity’den daha da bağımsız olabiliriz. Binding Adapter sayesinde özel fonksiyonlar oluşturabiliriz.</p><h3>Nasıl Kullanılır (Activity) ?</h3><p><strong>1- </strong>Öncelikle build.gradle(app) içine kütüphanemizi ekleyelim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1bb60298eb015d64f16e4fb525d3f4b9/href">https://medium.com/media/1bb60298eb015d64f16e4fb525d3f4b9/href</a></iframe><p><strong>2-</strong> Layout xml dosyamızı aşağıdaki gibi düzenleyelim. Sadece &lt;layout&gt; tagi eklemeliyiz. &lt;data&gt; bölümünü birazdan anlatacağım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19a55d6210791589245170989eeef7bd/href">https://medium.com/media/19a55d6210791589245170989eeef7bd/href</a></iframe><p><strong>3- </strong>Activity içerisine aşağıdaki kodları yazdıktan sonra binding değişkeni ile layout xml içerisindeki tüm nesnelere erişebiliriz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/359b65ab85a192c10c68f5bbb938ba11/href">https://medium.com/media/359b65ab85a192c10c68f5bbb938ba11/href</a></iframe><h3>Nasıl Kullanılır (Fragment) ?</h3><p><strong>1-</strong> Activity kullanımında yaptığımız gibi build gradle(app) içine kütüphaneyi ekleyelim</p><p><strong>2- </strong>Layout xml dosyamızı aşağıdaki gibi düzenleyelim.Bu sefer &lt;data&gt; bölümünü de dolduruyoruz. Aynı işlemi Activity için de yapabilirsiniz. Ben Fragment ile yapmayı tercih ettim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de5686ee5f1f4fb68c713d605dc9a193/href">https://medium.com/media/de5686ee5f1f4fb68c713d605dc9a193/href</a></iframe><p>Burada &lt;data&gt; içinde yer alan model sayesinde tasarım nesnelerine veri gönderebiliyorum. Binding Adapter sayesinde ImageView’de kolay bir şekilde resim gösterebiliyorum.</p><p><strong>3<em>-</em></strong> Model Sınıfını oluşturalım. Verileri bu sınıftan çekeceğiz ve layout üzerinde verileri Data Binding kullanarak göstereceğiz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c80f2cf422ffd31c812b33f53429c3f9/href">https://medium.com/media/c80f2cf422ffd31c812b33f53429c3f9/href</a></iframe><p>4- ImageView’de resim göstermek için Binding Adapter oluşturalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/776b1ea3a9025e5300aa46491f02e898/href">https://medium.com/media/776b1ea3a9025e5300aa46491f02e898/href</a></iframe><p><strong>5-</strong> HomeAdapter sınıfı ile row_item.xml dosyamızı Data Binding ile bağlıyoruz ve burada <em>binding.model = item</em> kodu ile verilerimizi layout xml dosyamıza gönderiyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/060e0458963053c4e8915b579af963e1/href">https://medium.com/media/060e0458963053c4e8915b579af963e1/href</a></iframe><p>6- Son adım olarak Fragment içindeki gerekli Data Binding kodlarını yazalım. Verileri ekranda görebilmek için HomeAdapter ile Fragment’ı bağlamamız gerekiyor. Konumuz Data Binding olduğu için o kodları eklemedim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ff241904be3b9ba1ceedeee87b5b423/href">https://medium.com/media/7ff241904be3b9ba1ceedeee87b5b423/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AaM8MlL92l6nhC-B.png" /><figcaption>Data Binding vs View Binding</figcaption></figure><h3>View Binding ve Data Binding Farkı Nedir ?</h3><ul><li>View Binding, kodunuzu belirli layout xml dosyalarına bağlamanın bir yoludur. Bu, görünüm özelliklerine doğrudan kodunuzdan erişmenizi ve bunları değiştirmenizi sağlar.</li><li>Data Binding, verileri layout xml dosyalarına bağlamanın bir yoludur. Bu, fazladan kod yazmadan verileri doğrudan görünümlerinize bağlamanıza olanak tanır.</li><li>Aşağıdaki görselde de gördüğünüz gibi Data Binding, View Binding’in yaptığı her şeyi kapsamaktadır. Bağlama düzenleri olarak ikisi de aynıdır. Data Binding, ek olarak XML dosyasındaki değişkenleri de kullanmamıza imkan tanır. Peki hangisini kullanmalıyız ?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Xe3FF2Z1CUXa8DvbnfTfw.png" /><figcaption>View Binding ve Data Binding</figcaption></figure><h3>Hangisini Kullanmalıyım ?</h3><ul><li>Bu sizin ihtiyaçlarınıza göre değişir.</li><li>View Binding, yalnızca layout dosyanızdaki nesnelere erişmeniz için iyi bir tercihtir.</li><li>Layout içindeki nesnelerinize veri göndermek gerekiyorsa Data Binding daha iyi bir seçim olacaktır.</li><li>Projenizde MVVM kullanıyorsanız , Data Binding kullanmanız daha iyi olacaktır.</li><li>Data Binding ile görünüme verileri de aktarabildiğimiz için MVVM ve temiz kod yapısına daha uyumlu olacaktır.</li></ul><blockquote>Projemizde Data Binding ve View Binding birlikte kullanılabilir. Verileri aktardığımız görünümlerde Data Binding , aktarmadığımız görünümlerde ise View Binding kullanabiliriz.</blockquote><h3>Ne Zaman View Binding , Ne Zaman Data Binding Kullanmalıyım ?</h3><p>Android projenizde bir kullanıcı arayüzü geliştiriyorsanız, layout içindeki nesnelere erişmek için iki seçeneğiniz vardır. Bunlar View Binding ve Data Binding. Her ikisinin de artıları ve eksileri vardır, bu nedenle her birinin ne zaman kullanılacağını bilmek önemlidir.</p><ul><li>View Binding, birkaç görünüme sahip basit UI’lar için uygundur. Kurulumu hızlı ve kolaydır. Ancak, derleme zamanına hataları kontrol edemediğinden Data Bindin’den daha az güvenli olabilir.</li><li>Data Binding, View Binding’e göre daha güçlüdür ve daha karmaşık düzenler için kullanılabilir. Ayrıca derleme zamanında hataları kontrol ettiğinden daha güvenilirdir.</li></ul><h3>Sonuç</h3><p>Hem View Binding hem de Data Binding’in kendi avantajları ve dezavantajları vardır, bu nedenle hangisini seçmeniz gerektiği ihtiyaçlarınıza bağlıdır. Eğer daha düzenli bir koda sahip olmak istiyorsanız ve verileri aktarmak istediğiniz bir projeniz var ise Data Binding kullanabilirsiniz. Layout dosyalarına daha hızlı ve kolay erişmek istiyorsanız ama veri aktarmak istemiyorsanız View Binding kullanabilirsiniz.</p><p>Bir makalenin daha sonuna geldik. Umarım sizler için faydalı bir makale olmuştur. Bir sonraki makalede görüşmek üzere. Kendinize iyi bakın.</p><h3>Referanslar</h3><ul><li><a href="https://developer.android.com/topic/libraries/view-binding">View binding | App architecture | Android Developers</a></li><li><a href="https://developer.android.com/topic/libraries/data-binding">Data Binding Library | Android Developers</a></li><li><a href="https://github.com/sezer1578/MVVMHiltDemoProject">GitHub - sezer1578/MVVMHiltDemoProject: This demo is developed using MVVM , Hilt and Room Database</a></li><li><a href="https://github.com/sezer1578/PagingSampleProject">GitHub - sezer1578/PagingSampleProject: Paging Sample</a></li><li><a href="https://stackoverflow.com/questions/58040778/android-difference-between-databinding-and-viewbinding">Android : Difference between DataBinding and ViewBinding</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c99ff7b01e8a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers-tr/nedir-bu-databinding-ve-viewbinding-farklar%C4%B1-ve-detayl%C4%B1-anlat%C4%B1m-c99ff7b01e8a">Nedir Bu DataBinding ve ViewBinding? Farkları ve Detaylı Anlatım</a> was originally published in <a href="https://medium.com/huawei-developers-tr">Huawei Developers - Türkiye</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developing a Book Store Application Using HUAWEI Services| HMS | Kotlin]]></title>
            <link>https://medium.com/huawei-developers/developing-a-book-store-application-using-huawei-services-hms-kotlin-ea36b3d89c8?source=rss-d31aaf4017d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea36b3d89c8</guid>
            <category><![CDATA[huawei-cloud-db]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mapkit]]></category>
            <category><![CDATA[hms]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Sezer Özaltun]]></dc:creator>
            <pubDate>Tue, 01 Nov 2022 07:12:38 GMT</pubDate>
            <atom:updated>2022-11-01T07:12:38.330Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://medium.com/huawei-developers/best-practices-for-android-development-b2d5896df272?source=collection_home---6------2-----------------------">👨🏼‍💻</a>Developing a Book Store Application Using HUAWEI Services| HMS | Kotlin</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YQ1ccI-65RYo8PT0uGqncQ.png" /><figcaption>HMS</figcaption></figure><h3><strong>Introduction</strong></h3><p>Hello everyone,</p><p>I’m going to explain how to develop Book Store application using HMS. First of all, I would like to talk about the Huawei Mobile Services that I use in this application. These are; Account Kit, Location Kit, Map Kit, Push Kit, Site Kit, Analytics Kit, Auth Service and Cloud DB. I will describe Location Kit, Map Kit, Site Kit and Cloud DB in this article. I would like to briefly talk about the services we will use respectively before I start coding.</p><h3>About Services</h3><h4><strong>1.Location Kit</strong></h4><p>Location Kit allows us to get device location quickly and it helps us build global location capabilities and expand your global business.</p><h4><strong>2.Map Kit</strong></h4><p>Map Kit provides powerful and convenient map services for you to easily implement personalized map display and interaction.</p><h4>3.Site Kit</h4><p>Site Kit helps your app attract more users by providing many search features such as location search, time zone search, geocoding and prefecture search.</p><h4>4.Cloud DB</h4><p>It is a database that provides seamless data synchronization between the device and the cloud and between devices and allows us to perform offline application operations.</p><p>Cloud DB uses data storage structure based on the Object Model. Data is stored as object in different DB Zone. Each object is a data record. Cloud DB Zone is a standalone storage space.</p><p><strong>Object Type:</strong> Represents every table in classical database logic.</p><p><strong>Cloud DB Zone: </strong>Represents the data region on the cloud side. It corresponds to the database name.</p><h3>Implementation</h3><p>Before starting the coding part, you need to integrate HMS Core into your application. You can click the link <a href="https://medium.com/huawei-developers/android-integrating-your-apps-with-huawei-hms-core-1f1e2a090e98">here </a>for this.</p><p>After integrating HMS Core, we need to give the necessary permissions and add the necessary libraries. For this, let’s first define the permissions in the Android Manifest File.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f1f139e5d721caae3898256f7c870cc/href">https://medium.com/media/8f1f139e5d721caae3898256f7c870cc/href</a></iframe><p>Now let’s add the necessary libraries in build.gradle(app).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a1c39dc6f403488467b90b25bd0827b/href">https://medium.com/media/0a1c39dc6f403488467b90b25bd0827b/href</a></iframe><p>We have given the permissions. Now we need to edit our layout xml file.</p><p>Let’s add the following codes in the activity_map.xml file of MapActivity.kt.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cc3b271b318aedd8f7cba50cfca2de2/href">https://medium.com/media/1cc3b271b318aedd8f7cba50cfca2de2/href</a></iframe><p>We have also finished our layout file. We can write the necessary codes in our MapActivity.kt file.</p><p>Before we start coding, we need to implement OnMapReadyCallBack for the map to work. After implementing, we create the variables we need.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdade7b912691a2c003193dc532a7823/href">https://medium.com/media/fdade7b912691a2c003193dc532a7823/href</a></iframe><p>After creating the variables, we need to install the Map Kit SDK. We write our code as below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51d8b2116fe4c0acc4dac18ac9fae7e8/href">https://medium.com/media/51d8b2116fe4c0acc4dac18ac9fae7e8/href</a></iframe><p>Now, we need to get some permissions to get the location. In addition, we need to do version control, as each device has a different android version installed. Let’s write these codes now.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40f60a215a9eb6ea0468446da496729b/href">https://medium.com/media/40f60a215a9eb6ea0468446da496729b/href</a></iframe><p>Now, we can move on to the use of Site Kit. First, let’s take our location.</p><p>We can get the instant location of the user using Fused Location while getting the location. If the user changes location, we call requestLocationUpdates.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2038d3ed3fc30141dce05a0457553af/href">https://medium.com/media/b2038d3ed3fc30141dce05a0457553af/href</a></iframe><p>We got our location. Everything is perfect. Let’s find nearby book stores. We will use NearbySearch, which is the Site Kit feature for this. You can see the codes below.</p><p><strong>location: </strong>User’s location</p><p><strong>radius: </strong>Specifies the area to scan. The default value is 1000.</p><p><strong>query: </strong>Keyword we want to search</p><p><strong>poitype: </strong>The type of place we want to search. For example we will use BOOKSTORE.</p><p><strong>NOTE: </strong>You should write your own application’s api in the field that says Huawei api key. You can check it on AppGalleryConnect.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e4becba179ead57fe915a1a518cada1/href">https://medium.com/media/5e4becba179ead57fe915a1a518cada1/href</a></iframe><p>We got the book stores near us through Site kit. Now let’s show them on the map. We will use the marker addition, which is the Map Kit feature. Thus, we will get a better image. I used a personalized icon when adding the marker. You can use the default icon if you wish.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd5a9ea4e295a04b21899216279190d7/href">https://medium.com/media/cd5a9ea4e295a04b21899216279190d7/href</a></iframe><p>Everything is perfect so far. Only one thing remains. We should show what we have done on the map. For this, as I said at the beginning of the article, we implemented OnMapReadyCallBack. After implementing it, it asks us to add override fun onMapReady. We add this and write the following codes in it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b36a92188559fba8716be509f1cae03/href">https://medium.com/media/1b36a92188559fba8716be509f1cae03/href</a></iframe><h3>Implementing Cloud DB</h3><p>We have worked with Location Kit, Map Kit and Site Kit so far. In our application, the books fetched through the Google Books Api are displayed and users who are logged into the application can add the books they want to their favorites. Users registered to the application and books added to favorites are kept on Cloud DB.</p><h3><strong>What Will We Do in Cloud DB?</strong></h3><p><strong><em>1- User registration</em></strong></p><p><strong><em>2- Show user data on profile page</em></strong></p><p><strong><em>3- Adding books to favorites</em></strong></p><p><strong><em>4- Deleting a book from favorites</em></strong></p><p><strong><em>5- Show books in favorites</em></strong></p><p>We have learned the operations performed on Cloud DB, we can move on to the coding part now.</p><p>First of all, we need to create Object Type on AppGallery Connect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/0*N9gTHBrs07cY2dk2.png" /><figcaption>Object Types</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/0*Kv356UodP0ayrgAF.png" /><figcaption>User Object Type</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/0*edoQMDo_nibt_NzW.png" /><figcaption>Book Object Type</figcaption></figure><p>Book Object Type also includes publishedDate (String) and isFavorite (Boolean).</p><p><strong>bookid :</strong> The id of the books.</p><p><strong>id :</strong> Users id</p><p>We created Object Types, we need to create Cloud Zone. After going to the Cloud DB Zones tab via AppGallery Connect, you can create it by clicking the Add button. I called it UserDB.</p><p>After everything is done, you need to export as Java. We take it as Java because it does not support Kotlin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/0*j5qxbzhYnxMF6S5t.png" /><figcaption>Export</figcaption></figure><p>You need to write the package name of your application where it says Package Name in the picture above,. After exporting, you must upload the files into Android Studio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/0*Pj9dpgJaK1VsViMY.png" /><figcaption>Files</figcaption></figure><p>Only Book,User and ObjectTypeInfoHelper will be in the files you download. Let’s create other files and let’s move on to our coding.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9824b6d74ae2f64bd5e3771f8fe6fb60/href">https://medium.com/media/9824b6d74ae2f64bd5e3771f8fe6fb60/href</a></iframe><p>We initialize the CloudDBZoneWrapper class and determine the zone area in the code above. I chose Germany when creating the DB, so I chose Germany here as well.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3814ac1594d61ddad0cb4296e46b755/href">https://medium.com/media/c3814ac1594d61ddad0cb4296e46b755/href</a></iframe><p>We determined the zone region respectively in the coding above. Then ,we create the createObjectType required for Cloud DB. In order to use Cloud DB, we need to open it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be3df162c2845cb0b39cceb99b2695cd/href">https://medium.com/media/be3df162c2845cb0b39cceb99b2695cd/href</a></iframe><p>Code that adds users registered to the application to Cloud DB.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9df3d8101313eae92a6ffc9389beabb0/href">https://medium.com/media/9df3d8101313eae92a6ffc9389beabb0/href</a></iframe><p>Here are the codes that allow us to query on Cloud DB to show user information on our Profile page.</p><p>User-related Cloud DB codes are finished, now let’s write for Books.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62dbd159a8cd1aba74f87ba40f221568/href">https://medium.com/media/62dbd159a8cd1aba74f87ba40f221568/href</a></iframe><p>It is almost the same as the user codes, but there is an additional delete function. We use CallBack to call these codes from related classes and not to overload them. You can see the codes below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdb32cb3b9995ed62d04ef22dd2a19e0/href">https://medium.com/media/cdb32cb3b9995ed62d04ef22dd2a19e0/href</a></iframe><p>Our codes in CloudDBZoneWrapper are finished. Now let’s do the User and Book operations, respectively.</p><p><strong>CloudDB User Operations</strong></p><p>When the user signs up for the app, his information will go to Cloud DB and user information will be fetched from Cloud DB on the profile page. Let’s do this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b32f61df93e7e7e22bf43a3e4ea3c3e4/href">https://medium.com/media/b32f61df93e7e7e22bf43a3e4ea3c3e4/href</a></iframe><p>In the above code snippet, when the user clicks the register button, their information is saved to Cloud DB. Since there is no AutoIncrement in Cloud DB, I defined the id from AuthService to the userId. Thus, the id of each user will be unique.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c1b01bbe16cb8556be622deca55c050/href">https://medium.com/media/8c1b01bbe16cb8556be622deca55c050/href</a></iframe><p>We took user information on the profile page and displayed it in the relevant TexViews. Here, I performed asynchronous operation with Kotlin Coroutines because the code when opening the Cloud DB Zone and the code we were querying conflicted in a very short time and I was getting a null error. I solved this error with coroutines.</p><p><strong>Cloud DB Book Operations</strong></p><p>Books are displayed on the homepage in the application. When the user clicks on any book, he is directed to the detail page of the book, where he see a favorite button that he can add to his favourites. When the user clicks on the favorite button, the relevant book is added to Cloud DB, and when the user clicks again, the relevant book is deleted from Cloud DB. The user can see the books they have added to their favorites on the favorites page. The books here are imported in Cloud DB.</p><p>This is the usecase we want to have in practice. Let’s code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7dbb7465b81af2d43a9953020c7c2027/href">https://medium.com/media/7dbb7465b81af2d43a9953020c7c2027/href</a></iframe><p>The book is added to favorites when the button is clicked. In other words, it is added to Cloud DB.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c0adc26bddf85d54bd8645392608c72/href">https://medium.com/media/0c0adc26bddf85d54bd8645392608c72/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f8fddc6c3910dd7118020a2dbe956cb/href">https://medium.com/media/5f8fddc6c3910dd7118020a2dbe956cb/href</a></iframe><p>Of course, we need to call UICallBack from CloudDBZoneWrapper class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f1e45df63852cfe4bf3d4f08e966556/href">https://medium.com/media/9f1e45df63852cfe4bf3d4f08e966556/href</a></iframe><p>The codes here is fatched the favorite books from Cloud DB and display them on the relevant page. I used Hashset to show the books uniquely.</p><p>Our Cloud DB operations are also finished. Now we can move on to the application images.</p><p>You can see the application screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*zpT2A6AsaFRDPc1F.jpeg" /><figcaption>Book Stores on Map</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*eJEPiyfvIKehwvUw.png" /><figcaption>Cloud DB (Book)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*5KHKvZCAZB4023uJ.png" /><figcaption>Cloud DB (User)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VGTIqD-GZrahe0g9z1vSOg.png" /><figcaption>Screenshots in the App</figcaption></figure><h3>Significant</h3><ul><li>FingerPrint needs to be defined on AppGalleryConnect</li><li>When using Site Kit, encoding is required when defining Api key</li><li>To use Site Kit on Map Kit, RequiresPermission is required.</li><li>If you get a null error while using Cloud DB, you can solve it using Kotlin Coroutines.</li></ul><h3>Conclusion</h3><p>We have developed an application that displays the book stores near us using location kit, map kit and site kit, and keeps users and books in the DB using Cloud DB in this article. I hope it has been a useful resource for you. See you in the next article. Take care of yourselves.</p><h3>References</h3><ul><li><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/introduction-0000001050706106">Document</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-sdk-introduction-0000001061991291">Document</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-sdk-about-the-service-0000001076188604">Document</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-clouddb-introduction-0000001054212760">Document</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-auth-introduction-0000001053732605">Document</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea36b3d89c8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/developing-a-book-store-application-using-huawei-services-hms-kotlin-ea36b3d89c8">Developing a Book Store Application Using HUAWEI Services| HMS | Kotlin</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HUAWEI Servisleri Kullanarak Book Store Uygulaması Geliştirmek| HMS | Kotlin]]></title>
            <link>https://medium.com/huawei-developers-tr/huawei-servisleri-kullanarak-book-store-uygulamas%C4%B1-geli%C5%9Ftirmek-hms-kotlin-f4447aca5060?source=rss-d31aaf4017d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4447aca5060</guid>
            <category><![CDATA[huawei-cloud-db]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[hms]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mapkit]]></category>
            <dc:creator><![CDATA[Sezer Özaltun]]></dc:creator>
            <pubDate>Wed, 14 Sep 2022 11:50:46 GMT</pubDate>
            <atom:updated>2022-09-14T11:50:46.081Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zXdXVXE_-5WLaaspTDma2w.png" /><figcaption>HMS Servisleri</figcaption></figure><h3><strong>GİRİŞ</strong></h3><p>Herkese merhabalar,</p><p>Bu makalede sizlere Huawei servislerini kullanarak Book Store uygulamasını nasıl geliştirdiğimi anlatacağım. Öncelikle bu uygulama içerisinde kullandığım servislerden bahsetmek istiyorum. Bunlar ; Account Kit, Location Kit, Map Kit, Push Kit, Site Kit, Analytics Kit, Auth Service ve Cloud DB. Bu makalede Location Kit, Map Kit , Site Kit ve Cloud DB’yi anlatacağım. Kodlamaya başlamadan önce kısaca sırasıyla kullanacağımız servislerden bahsetmek istiyorum.</p><h3>SERVİSLER HAKKINDA</h3><h4><strong>1.Location Kit</strong></h4><p>Location Kit, cihaz konumunu hızlı bir şekilde almamıza olanak sağlar ve global konum yetenekleri oluşturmamıza ve global işinizi genişletmenize yardımcı olur.</p><h4><strong>2. Map Kit</strong></h4><p>Map Kit, kişiselleştirilmiş harita gösterimini ve etkileşimi kolaylıkla uygulamanız için güçlü ve kullanışlı harita hizmetleri sağlar.</p><h4><strong>3. Site Kit</strong></h4><p>Site Kit, yer arama, saat dilimi arama, coğrafi kodlama ve idari bölge arama gibi birçok arama özelliği sunarak uygulamanızın daha fazla kullanıcı çekmesine yardımcı olur.</p><h4><strong>4. Cloud DB</strong></h4><p>Cihaz ile cloud arasında ve cihazlar arasında sorunsuz veri senkronizasyonu sağlayan ve çevrimdışı uygulama işlemlerini gerçekleştimemizi sağlayan bir veritabanıdır.</p><p>Cloud DB, Object Modele dayalı veri depolama yapısını kullanır. Veriler object olarak farklı DB Zone bolgesinde depolanır. Her object bir veri kaydıdır. Cloud DB Zone bağımsız bir depolama alınıdır.</p><p><strong>Object Type :</strong> Klasik veritabanı mantığında bulunan her bir tabloyu teslim eder.</p><p><strong>Cloud DB Zone : </strong>Cloud tarafındaki veri bolgesini teslim eder. Veritabanı adına karşılık gelir.</p><h3>UYGULAMA</h3><p>Kodlama kısmına başlamadan önce uygulamanıza HMS Core entegre etmeniz gerekiyor. Bunun için <a href="https://medium.com/huawei-developers-tr/android-uygulamalar%C4%B1n%C4%B1za-huawei-hms-core-entegre-edin-542476f58910"><em>buradaki</em></a><em> </em>bağlantıya tıklayabilirsiniz.</p><p>HMS Core entegre ettikten sonra gerekli izinleri vermemiz ve gerekli kütüphaneleri eklememiz gerekiyor.</p><p>Bunun için öncelikle Android Manifest Dosyasındaki izinleri tanımlayalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f1f139e5d721caae3898256f7c870cc/href">https://medium.com/media/8f1f139e5d721caae3898256f7c870cc/href</a></iframe><p>Şimdi ise build.gradle(app) içinde gerekli kütüphaneleri ekleyelim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a1c39dc6f403488467b90b25bd0827b/href">https://medium.com/media/0a1c39dc6f403488467b90b25bd0827b/href</a></iframe><p>İzinleri verdik. Şimdi ise layout xml dosyamızı düzenlememiz gerekiyor.</p><p>MapActivity.kt’ye ait activity_map.xml dosyası içinde aşağıdaki kodları ekleyelim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cc3b271b318aedd8f7cba50cfca2de2/href">https://medium.com/media/1cc3b271b318aedd8f7cba50cfca2de2/href</a></iframe><p>Layout dosyamızı da bitirdik. MapActivity.kt dosyamızın içerisinde gerekli kodları yazabiliriz.</p><p>Kodlamaya başlamadan önce haritanın çalışabilmesi için OnMapReadyCallBack implement etmemiz gerekiyor. Implement ettikten sonra ihtiyacımız olan değişkenleri oluşturuyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdade7b912691a2c003193dc532a7823/href">https://medium.com/media/fdade7b912691a2c003193dc532a7823/href</a></iframe><p>Değişkenleri oluşturduktan sonra şimdi de map kit SDK’ yı yüklememiz gerekiyor. Aşağıdaki gibi kodlarımızı yazıyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51d8b2116fe4c0acc4dac18ac9fae7e8/href">https://medium.com/media/51d8b2116fe4c0acc4dac18ac9fae7e8/href</a></iframe><p>Şimdi ise konumu almak için bazı izinleri almamız gerekiyor. Ayrıca her cihazda farklı android sürümü yüklü olduğu için versiyon kontrolü de yapmamız gerekiyor. Hadi şimdi de bu kodları yazalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40f60a215a9eb6ea0468446da496729b/href">https://medium.com/media/40f60a215a9eb6ea0468446da496729b/href</a></iframe><p>Şimdi ise Site Kit kullanımına geçebiliriz. Öncelikle konumumuzu alalım.</p><p>Konumu alırken Fused Location kullanarak kullanıcının anlık konumunu alabiliyoruz. Eğer kullanıcı konumu değiştirirse requestLocationUpdates çağırıyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2038d3ed3fc30141dce05a0457553af/href">https://medium.com/media/b2038d3ed3fc30141dce05a0457553af/href</a></iframe><p>Konumumuzu aldık. Her şey mükemmel. Hadi yakındaki kitap mağazalarını bulalım. Bunun için Site Kit özelliği olan NearbySearch kullanacağız. Kodları aşağıda görebilirsiniz.</p><p><strong>location : </strong>Kullanıcının konumu</p><p><strong>radius:</strong> tarama yapacağımız alanı belirtir. Default değeri 1000 dir.</p><p><strong>query:</strong> arama yapmak istediğimiz keyword</p><p><strong>poitype:</strong> arama yapmak istediğimiz yerin tipi. Örneğin biz BOOKSTORE kullanacağız.</p><p><strong>NOT :</strong> Huwai api key yazan alana kendi uygulamanızın apisini yazmalısınız. AppGalleryConnect üzerinden bakabilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e4becba179ead57fe915a1a518cada1/href">https://medium.com/media/5e4becba179ead57fe915a1a518cada1/href</a></iframe><p>Yakınımızdaki kitap mağazalarını aldık. Şimdi ise bunları harita üzerinde gösterelim. Map Kit özelliği olan marker eklemeyi kullanacağız. Böylece daha güzel bir görüntü elde edeceğiz. Marker eklerken kişiselleştirilmiş bir ikon kullandım. Siz dilerseniz default ikon kullanabilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd5a9ea4e295a04b21899216279190d7/href">https://medium.com/media/cd5a9ea4e295a04b21899216279190d7/href</a></iframe><p>Şu ana kadar her şey mükemmel. Tek bir şey kaldı. Harita üzerinde yaptıklarımızı göstermek. Bunun için yazının en başında söylediğim gibi OnMapReadyCallBack implement etmiştik. Implement ettikten sonra bize override fun onMapReady eklememizi istiyor. Bunu ekliyoruz ve içine aşağıdaki kodları yazıyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b36a92188559fba8716be509f1cae03/href">https://medium.com/media/1b36a92188559fba8716be509f1cae03/href</a></iframe><h3>CLOUD DB İLE ÇALIŞMAK</h3><p>Şu ana kadar Location Kit, Map Kit ve Site Kit ile çalıştık. Uygulamız içerisinde Google Books Api üzerinden alınan kitaplar gösteriliyor ve uygulamaya giriş yapmış kullanıcılar istediği kitapları favorilerine ekleyebiliyorlar. Uygulamaya kayıt olan kullanıcılar ve favorilere eklenen kitaplar Cloud DB üzerinde tutuluyor.</p><p><strong>Cloud DB’de Yapılan İşlemler</strong></p><p><strong><em>1- Kullanıcı kaydı</em></strong></p><p><strong><em>2- Kullanıcı verilerini profil sayfasında gösterme</em></strong></p><p><strong><em>3- Favorilere kitap ekleme</em></strong></p><p><strong><em>4- Favorilerden kitap silme</em></strong></p><p><strong><em>5- Favorilerdeki kitapları gösterme</em></strong></p><p>Cloud DB üzerinde yapılan işlemleri de öğrendiğimize göre şimdi kodlama kısmına geçebiliriz.</p><p>Öncelikle AppGallery Connect üzerinden Object Type oluşturmalıyız.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*PXD1pq9YeDHjmJhM_TeyGw.png" /><figcaption>Object Types</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*7NgJIFrPFxhrT6CggjNUHA.png" /><figcaption>User Object Type</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*hqqmiMQcRogvTvMRQdSb3Q.png" /><figcaption>Book Object Type</figcaption></figure><p>Book Object Type içinde ek olarak publishedDate (String) ve isFavorite (Boolean) yer alıyor.</p><p>bookid : Kitapların id’si.</p><p>id : Kullanıcıların id’si</p><p>Object Typeları oluşturduk şimdi ise Cloud Zone oluşturmamız gerekiyor. AppGallery Connect üzerinden Cloud DB Zones sekmesine geldikten sonra Add butonuna tıklayarak oluşturabilirsiniz. Ben adına UserDB dedim.</p><p>Her şey bittikten sonra Java olarak Export almanız gerekiyor. Kotlin desteği olmadığı için Java olarak alıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*pyX41OI7buz3twAn5kb_Yg.png" /><figcaption>Export</figcaption></figure><p>Yukarıdaki resimde Package Name yazan yere kendi uygulamanızın paket adını yazmanız gerekiyor. Export aldıktan sonra dosyaları Android Studio içine yüklemelisiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*AuTsDYrIaGs1QztPN8u-Aw.png" /><figcaption>Dosyalar</figcaption></figure><p>Sizin indirdiğiniz dosyalarda sadece Book,User ve ObjectTypeInfoHelper olacaktır. Diğer dosyalarıda oluşturalım ve hadi kodlamamıza geçelim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9824b6d74ae2f64bd5e3771f8fe6fb60/href">https://medium.com/media/9824b6d74ae2f64bd5e3771f8fe6fb60/href</a></iframe><p>Yukarıdaki kodlamada CloudDBZoneWrapper sınıfını initialize ediyoruz ve zone bölgesini belirliyoruz. Ben DB yi oluştururken Germany seçmiştim o yüzden burada da Germany seçtim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3814ac1594d61ddad0cb4296e46b755/href">https://medium.com/media/c3814ac1594d61ddad0cb4296e46b755/href</a></iframe><p>Yukarıdaki kodlamada sırasıyla zone bölgesini belirliyoruz. Sonrasında ise Cloud DB için gerekli olan createObjectType oluşturuyoruz. Veee Cloud DB’yi kullanabilmemiz için açmamız gerekiyor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be3df162c2845cb0b39cceb99b2695cd/href">https://medium.com/media/be3df162c2845cb0b39cceb99b2695cd/href</a></iframe><p>Uygulamaya kayıt olan kullanıcıları Cloud DB’ye ekleyen kodumuz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9df3d8101313eae92a6ffc9389beabb0/href">https://medium.com/media/9df3d8101313eae92a6ffc9389beabb0/href</a></iframe><p>Burada ise Profil sayfamızda kullanıcı bilgilerini göstermek için Cloud DB üzerinde sorgulama yapmamızı sağlayan kodlar yer alıyor.</p><p>Kullanıcı ile ilgili Cloud DB kodları bitti şimdi Kitaplar için yazalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62dbd159a8cd1aba74f87ba40f221568/href">https://medium.com/media/62dbd159a8cd1aba74f87ba40f221568/href</a></iframe><p>Aslında user kodları ile neredeyse aynı sadece ek olarak delete fonksiyonu yer alıyor. Bu yazdığımız kodları ilgili sınıflardan çağırmak ve yük bindirmemk için CallBack kullanıyoruz. Aşağıda kodları görebilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdb32cb3b9995ed62d04ef22dd2a19e0/href">https://medium.com/media/cdb32cb3b9995ed62d04ef22dd2a19e0/href</a></iframe><p><strong>CloudDBZoneWrapper </strong>içindeki kodlarımız bitti. Şimdi sırasıyla User ve Book işlemlerini yapalım.</p><p><strong>Cloud DB User İşlemleri</strong></p><p>Bir kullanıcı uygulamamıza kayıt olduğu anda bilgileri Cloud DB’ye gidecek ve profil sayfasında da kullanıcı bilgileri Cloud DB’den çekilecek. Hadi yapalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b32f61df93e7e7e22bf43a3e4ea3c3e4/href">https://medium.com/media/b32f61df93e7e7e22bf43a3e4ea3c3e4/href</a></iframe><p>Yukarıdaki kod parçasında kullanıcı kayıt ol butonuna tıkladığı anda bilgileri Cloud DB’ye kayıt ediliyor. Cloud DB’de AutoIncrement olmadıgı için userId ye AuthService’den gelen id’yi tanımladım. Böylece her kullanıcının id’si benzersiz oldu.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c1b01bbe16cb8556be622deca55c050/href">https://medium.com/media/8c1b01bbe16cb8556be622deca55c050/href</a></iframe><p>Profil sayfasında kullanıcı bilgerini aldık ve ilgili TexView’lerde gösterdik. Burada Kotlin Coroutines ile asenkron işlem gerçekleştirdim çünkü Cloud DB Zone açılırken ki kod ile query yaptığımız kod çok kısa bir sürede bir yerde çakışıyordu ve null hatası alıyordum. Coroutines ile bu hatayı çözdüm.</p><p><strong>Cloud DB Book İşlemleri</strong></p><p>Uygulama içerisinde Anasayfada kitaplar gösteriliyor. Kullanıcı herhangi bir kitaba tıkladığı zaman kitabın detay sayfasına yönlendiriliyor ve burada favorilere ekleyebileceği bir kalp butonu görüyor. Kullanıcı kalbe tıkladığı zaman ilgili kitap Cloud DB’ye ekleniyor , tekrar tıkladığında ise ilgili kitap Cloud DB’den siliniyor. Kullanıcı favorilere eklediği kitaplarını favoriler sayfasında görebiliyor. Buradaki kitaplar ise Cloud DB’de alınıyor.</p><p>Uygulamda olmasını istediğimiz case bu şekilde. Hadi kodlayalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7dbb7465b81af2d43a9953020c7c2027/href">https://medium.com/media/7dbb7465b81af2d43a9953020c7c2027/href</a></iframe><p>Butona tıklandığı anda kitap favorilere ekleniyor. Bir başka deyişle Cloud DB’ye ekleniyor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c0adc26bddf85d54bd8645392608c72/href">https://medium.com/media/0c0adc26bddf85d54bd8645392608c72/href</a></iframe><p>Kitapları Cloud DB’den silen kodumuz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f8fddc6c3910dd7118020a2dbe956cb/href">https://medium.com/media/5f8fddc6c3910dd7118020a2dbe956cb/href</a></iframe><p>Tabii ki CloudDBZoneWrapper sınıfından UICallBack’i çağırmamız gerekiyor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f1e45df63852cfe4bf3d4f08e966556/href">https://medium.com/media/9f1e45df63852cfe4bf3d4f08e966556/href</a></iframe><p>Buradaki kodlar ise favoriye eklenen kitapları Cloud DB’den çekiyor ve ilgili sayfada gösteriyor. Kitapları benzersiz göstermesi için Hashset kullandım.</p><p>Cloud DB işlemlerimiz de bitti. Şimdi uygulama görüntülerine geçebiliriz.</p><p>Uygulama ekran görüntüsünü aşağıda görebilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3fcvXRhxYuoltfyYGCxxmw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MRb1-EVaJMMPmKptftyJWQ.png" /><figcaption>Cloud DB (Book)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vcuwyEKACdxc9oF_rPwSqQ.png" /><figcaption>Cloud DB (User)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*feZScmKz8geH7JqLGXF2Pw.png" /></figure><h3><strong>ÖNEMLİ</strong></h3><ul><li>AppGalleryConnect üzerinden FingerPrint tanımlanması gerekiyor</li><li>Site Kit kullanırken Api key tanımlarken encode yapılması gerekiyor</li><li>Map Kit üzerinde Site Kit kullanabilmek için RequiresPermission yapılması gerekiyor.</li><li>Cloud DB kullanırken null hatası alırsanız Kotlin Coroutines kullanarak çözebilirsiniz.</li></ul><h3>SONUÇ</h3><p>Bu yazımda, location kit, map kit ve site kit kullanarak yakınımızda bulunan kitap mağazalarını gösteren ve Cloud DB kullanarak ise kullanıcı ve kitapları DB’de tutan bir uygulama geliştirdik. Umarım sizler için faydalı bir kaynak olmuştur. Bir sonraki makalede görüşmek üzere. Kendinize iyi bakın.</p><h3>REFERANSLAR</h3><ul><li><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/introduction-0000001050706106">Document</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-sdk-introduction-0000001061991291">Document</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-sdk-about-the-service-0000001076188604">Document</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-clouddb-introduction-0000001054212760">Document</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-auth-introduction-0000001053732605">Document</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4447aca5060" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers-tr/huawei-servisleri-kullanarak-book-store-uygulamas%C4%B1-geli%C5%9Ftirmek-hms-kotlin-f4447aca5060">HUAWEI Servisleri Kullanarak Book Store Uygulaması Geliştirmek| HMS | Kotlin</a> was originally published in <a href="https://medium.com/huawei-developers-tr">Huawei Developers - Türkiye</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fragment Nedir? Neden Kullanırız ? | Android]]></title>
            <link>https://medium.com/@sezerozaltunn/fragment-nedir-neden-kullan%C4%B1r%C4%B1z-android-151971d140bf?source=rss-d31aaf4017d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/151971d140bf</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[fragments]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Sezer Özaltun]]></dc:creator>
            <pubDate>Mon, 16 May 2022 17:50:02 GMT</pubDate>
            <atom:updated>2022-05-16T17:50:02.560Z</atom:updated>
            <content:encoded><![CDATA[<h3>Fragment Nedir? Neden Kullanırız ? | Android</h3><h3><strong>Giriş</strong></h3><p>Merhabalar, bu yazımda android uygulamalarında oldukça kullanılan Fragment yapısını inceleyeceğiz. Fragment nedir? Neden kullanılır ? Neden Activity değil de Fragment kullanmalıyız? Avantajları nedir gibi soruların cevaplarını bulabileceksiniz. Hadi başlayalım…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gtj2EMQlEfakqUnCHhNNoA.jpeg" /></figure><h3>Fragment Nedir ?</h3><p>Android dökümanına göre fragment , Activity’e bağlı olan kullanıcı arayüzünün bir parçasıdır. Fragment’ların kendilerine özgü bir yaşam döngüleri (lifecycle) ve UI bileşenleri vardır. Fragment’lar kullanıcı arayüzünü (UI) tasarımını zenginleştirmeye , ekranlar arasında veri aktarmaya ve farklı cihaz boyutlarına uyum sağlamaya yardımcı olur.</p><h3>Fragment Lifecycle(Yaşam Döngüsü) Nedir ?</h3><p>Activity’ler gibi Fragment’ların da yaşam döngüleri vardır. Peki bunlar nelerdir ?</p><p>Öncelikle Fragment, yaşam döngüsünü yönetmek için LifecycleOwner ‘ ı uygular. Buna, getLifecycle() yöntemi ile erişebilirsiniz. Her olası lifecycle durumu Lifecycle.State enum’unda temsil edilir. Bu yaşam döngüleri 5 ana başlık altında incelenmektedir. Bu yaşam döngüleri; INITIALIZED, CREATED, STARTED, RESUMED ve DESTROYED dir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*9-Y2heyDpg2FE21VKVbC4A.png" /></figure><p><strong>onCreate(): </strong>Fragment oluşturulurken bu metod çağırılır. Fragment, duraklatıldığında veya durdurulduğunda ve ardından devam ettirildiğinde tutmak istediğiniz temel bileşenleri başlatır.</p><p><strong>onCreateView(): </strong>UI ilk kez ekranda gösterileceği zaman bu metod çağırılır. Layout xml dosyası burada kullanabilirsiniz.</p><p><strong>onViewCreated (): </strong>Bazen layout xml dosyamız başlatıldığı zaman onCreateView de bazı hatalarla karşılaşabiliyoruz. Bunun için layout xml dosyanızı burada tanımlayabilirsiniz. Diğer widgetları ise onCreateView() içerisinde çağırabilirsiniz. onViewCreated(), görünümün tamamen oluştuğundan emin olmaktadır.</p><p><strong>onViewStateRestored(): </strong>Fragment içerisine, görünüm hiyerarşisinin tüm kaydedilmiş durumunun geri yüklendiğini söyler.</p><p><strong>onStart(): </strong>Fragment görünür hale geldiğinde çağırılır.</p><p><strong>onResume(): </strong>Fragment aktif hale gelir.</p><p><strong>onPause(): </strong>Android, Kullanıcının, Fragment’tan ayrıldığınının ilk göstergesi olarak bu metodu çağırır. Bu genellikle , kalıcı olması gereken değişiklikleri gerçekleştirmeniz gereken yerdir.</p><p><strong>onStop():</strong> Fragment durdurulur.</p><p><strong>onSaveInstanceState(): </strong>Fragment’ın nasıl çalıştığının dinamik durumunu yönetmekten sorumludur.</p><p><strong>onDestroyView(): </strong>Fragment yok edilecektir.</p><p><strong>onDestroy(): </strong>Fragment durumunun son temizliği yapılır. Android platformu tarafından çağırılacağı garanti edilemez.</p><h3>Neden Fragment Kullanmalıyız ?</h3><ul><li>Eğer uygulamanız içerisinde, TabLayout, BottomNavigation veya NavigationView gibi özellikler kullanacaksanız kesinlikle Fragment kullanmalısınız. Çünkü en yüksek verimi ve uyumu Fragment ile elde edersiniz</li><li>FragmentManager sizin için back(geri) tuşu işlemini çok akıllı bir şekilde gerçekleştirir.</li><li>ViewPager oluşturmak içinFragmentPagerAdapter kullanabilirsiniz. FragmentPagerAdapter çok daha verimli ve kullanması kolay bir yapıdır Ayrıca, Fragment’ların örneklemelerini denetler.</li><li>Hem telefonlar hem de tabletler için uygulama geliştirdiğinizde Fragment’lar hayatınızı çok daha kolaylaştıracaktır. Uyumluluk üst düzeydedir.</li><li>Sürekli yeni bir Activity başlatmak yerine Fragment ile tek bir Activity içerisinde birden fazla sayfa kullanabilirsiniz.</li><li>Bir Fragment birden fazla Activity içerisinde kullanılabilir.</li></ul><h3>SON</h3><p>Okuduğunuz için teşekkürler. Umarım sizler için faydalı bir kaynak olmuştur..</p><h3>KAYNAKÇA</h3><blockquote><a href="https://www.section.io/engineering-education/all-about-fragments-in-android-applications/">https://www.section.io/engineering-education/all-about-fragments-in-android-applications/</a></blockquote><blockquote><a href="https://developer.android.com/guide/fragments/lifecycle">https://developer.android.com/guide/fragments/lifecycle</a></blockquote><blockquote><a href="https://www.tutorialspoint.com/android/android_fragments.htm">https://www.tutorialspoint.com/android/android_fragments.htm</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=151971d140bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android-Kotlin Navigation Component Nedir , Nasıl Kullanılır ?]]></title>
            <link>https://medium.com/@sezerozaltunn/android-kotlin-navigation-component-nedir-nas%C4%B1l-kullan%C4%B1l%C4%B1r-a1555ca189da?source=rss-d31aaf4017d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1555ca189da</guid>
            <category><![CDATA[navigation-component]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-navigation]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Sezer Özaltun]]></dc:creator>
            <pubDate>Mon, 18 Apr 2022 19:29:07 GMT</pubDate>
            <atom:updated>2022-04-18T19:38:29.560Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android-Kotlin Navigation Component Nedir , Nasıl Kullanılır ?</h3><h3><strong>Giriş</strong></h3><p>Navigation Component, uygulamanız genelinde sayfalar arasında gezinme akışlarını oluşturan ve düzenlemeyi çok daha kolay hale getiren Android Studio’daki API ve tasarım aracıdır. Navigation Component öncesinde fragmentlar arasında ekran geçişlerini kodlar ile yapıyorduk ve Toolbar üzerindeki geri butonunu da kontrol etmek için ayrı bir kod yazıyorduk. Ancak şimdi her şey daha net, kolay ve tutarlı hale geldi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7NvdxXczMZxmnVA46Epu0A.jpeg" /></figure><h3>Navigation Component Avantajları</h3><ul><li>Fragment işlemlerinin otomatik olarak işlenmesi</li><li>Varsayılan olarak ileri ve geri sayfa hareketleri</li><li>Animasyonlar ve geçişler ekleme</li><li>Çok az ek kodlama ile kullanıcı arabirimlerinde(navigation drawer ve bottom navigation) sayfalar arası gezinme</li><li>Navigasyon sırasında bilgi aktarırken güvenli ve kolaydır</li></ul><h3><strong>Navigation Components Kütüphanesi Nasıl Eklenir ?</strong></h3><ol><li>build.gradle(Module) dosyasını açın</li></ol><pre>//En üstte yer alan plugins bölümüne alttaki kodu ekleyin</pre><pre>id(&quot;androidx.navigation.safeargs&quot;)</pre><pre>//dependecies bölümüne alttaki kodu ekleyin</pre><pre>implementation &#39;androidx.navigation:navigation-fragment-ktx:2.4.1&#39;<br>implementation &#39;androidx.navigation:navigation-ui-ktx:2.4.1&#39;</pre><p>2. build.gradle(Project) dosyasını açın</p><pre>//En üstte alttaki kodu ekleyin</pre><pre>buildscript <strong>{<br>    </strong>repositories <strong>{<br>        </strong>google()<br>    <strong>}<br>    </strong>dependencies <strong>{<br>        </strong>classpath(&quot;androidx.navigation:navigation-safe-args-gradle-plugin:2.4.1&quot;)<br><br>    <strong>}<br>}</strong></pre><p>3. Projenizi sync edin ve ilgili kütüphanenin indirilmesini bekleyin.</p><h3>Navigation Component Kullanımı</h3><ol><li>Önce Fragmentlar oluşturmanız gerekiyor.</li><li>Fragmentları oluşturduktan sonra res klasörüne sağ tıklayın ve aşağıdaki görselden Android Resource Directory olanı seçin.</li></ol><p><strong>Not:</strong> Örnekte viewBinding kullandığım için id tanımlamaları farklı olabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Y8hWw-ez5x5EzaNhFEMjA.png" /><figcaption>Android Resource Directory Penceresi</figcaption></figure><p>3. Daha sonra açılan pencereden navigation seçin ve Ok butonuna tıklayın</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vcr2Zz0HCwejzzIvFCgBRg.png" /><figcaption>Navigation Penceresi</figcaption></figure><p>4. Res klasörü altında navigation klasörü oluşacaktır. Bu klasörün üzerine sağ tıklayıp yeni navigation resource oluşturmanız gerekiyor. Aşağıdaki görselden de görebileceğiniz gibi ben dosyanın adına nav_graph verdim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uMkbxzJdxOkFNno3Dp-GWg.png" /><figcaption>Navigation Resource Penceresi</figcaption></figure><p>5. nav_graph.xml üzerine çift tıklayın ve ilgili ekranı açın. Öncelikle karşınıza boş bir ekran gelecektir çünkü önceden oluşturduğumuz fragmentları henüz buraya eklemedik. Hadi şimdi fragmentları ekleyelim. Aşağıdaki görseldeki gibi kırmızı ok ile işaretlenmiş butona tıkladığınızda oluşturmuş olduğunuz tüm fragmentları görebilirsiniz. Hepsini eklemeniz gerekiyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c-1Ds9A-mGWlmYcnIBDgXw.png" /><figcaption>Navigation İçine Fragment Ekleme Penceresi</figcaption></figure><p>6. Fragmentları ekledikten sonra aşağıdaki görseldeki gibi bir ekran ile karşılacaksınız. Ben yönlendirmeleri de yaptığım için sizde yönlendirmeler gözükmeyecek ama yönlendirme yapmak çok basit. Fragment ekranın yanında bulunan küçük daireyi istediğiniz ekrana sürükleyince sayfa yönlendirmesi yapabiliyorsunuz.</p><ul><li>Yaptığınız her yönlendirmeye ait <strong>id</strong> oluşturulur. İsterseniz sağ taraftaki id bölümünden değiştirebilirsiniz. Sayfa kontrolünü bu <strong>id</strong> ile yapacağız.</li><li>Navigation Ekleme İşlemi bitti. Şimdi sıra Navigation’ı Activity içerisinde kullanmak. Hadi yapalım.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DJwsdW3HVXGLwiLYF4F2Og.png" /><figcaption>Navigation Graph Penceresi</figcaption></figure><h3><strong>Activity İçerisinde Navigation Kullanımı</strong></h3><ol><li>activity_main.xlm dosyası içerisinde oluşturduğumuz nav_graph.xml dosyasını tanımlamalıyız. Aşağıdaki görseldeki gibi tanımlamamızı yapıyoruz.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RWK5wBJx52diPI6Vus52-A.png" /><figcaption>activity_main.xml</figcaption></figure><p>2. MainActivity içerisinde NavigationController tanımlaması yapıyoruz. Bu tanımlama nav_graph ‘ ın çalışması içindir. Ayrıca onSupportNavigateUp metodu ile Toolbar üzerinde geri butonu oluşturuyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-sBb35MlxtADl-kSnFmU7g.png" /><figcaption>MainActivity</figcaption></figure><p>3. Her fragment içersine gitmek istediğiniz fragmetin id ‘sini yazmanız gerekiyor. Örneğin ben HomeFragment sayfasından CreateFragment sayfasına gitmek istiyorum ve bunun için de aşağıdaki kodu yazmam gerekiyor. Id olarak nav_graph.xml dosyasında belirlerdiğimiz id’yi yazıyoruz.</p><pre>Navigation.findNavController(it!!).navigate(R.id.<em>action_createFragment_to_homeFragment</em>)</pre><h3>Son</h3><p>Navigation Component kullanımı bu kadardı. Umarım sizler için faydası olmuştur. Okuduğunuz için teşekkürler.</p><h3>Kaynakça</h3><p><a href="https://github.com/sezer1578/NotesApp">https://github.com/sezer1578/NotesApp</a></p><p><a href="https://developer.android.com/guide/navigation/navigation-getting-started#kts">https://developer.android.com/guide/navigation/navigation-getting-started#kts</a></p><p><a href="https://medium.com/@muhamed.riyas/navigation-component-the-complete-guide-c51c9911684">https://medium.com/@muhamed.riyas/navigation-component-the-complete-guide-c51c9911684</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1555ca189da" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>