<?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 Nesya Viola on Medium]]></title>
        <description><![CDATA[Stories by Nesya Viola on Medium]]></description>
        <link>https://medium.com/@nesyavsh31?source=rss-646653cb993------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*OkR6INEBs3OkTfIp.jpg</url>
            <title>Stories by Nesya Viola on Medium</title>
            <link>https://medium.com/@nesyavsh31?source=rss-646653cb993------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 09:44:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nesyavsh31/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[Lesson 10 : 10.1 Part B: Deleting data from a Room database]]></title>
            <link>https://medium.com/@nesyavsh31/lesson-10-10-1-part-b-deleting-data-from-a-room-database-8b5560b89fcf?source=rss-646653cb993------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b5560b89fcf</guid>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Nesya Viola]]></dc:creator>
            <pubDate>Thu, 25 Apr 2019 01:02:56 GMT</pubDate>
            <atom:updated>2019-04-25T01:02:56.432Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lesson 10 : 10.1 Part B: Deleting data from a Room database</h3><h3>10.1 Part B: Deleting data from a Room database</h3><p>by Nesya Viola</p><h3>Task 1: Initialize data only if the database is empty</h3><p>In the WordDao interface, add a method to get any word</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D39eotvw6uAfFiSqwSeZbg.png" /></figure><p>In PopulateDBAsync, update the doInBackGround() method to check whether the database has any words before initializing the data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BtuE27XFNLNkc-MqvwwXjw.png" /></figure><h3>Task 2: Delete all words</h3><p>In WordDao, check that the deleteAll() method is defined and annotated with the SQL that runs when the method executes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BSlGqm3TedJ2unviJoFKIg.png" /></figure><p>In WordRepository, define deleteAllWordlAsynTask as an inner class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O0pmHToNxqU-7Womii8R0A.png" /></figure><p>In the WordRepository class, add the deleteAll() method to invoke the AsynTask that you defined</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yJZoS4j8Xj7HP8tbqXNNEA.png" /></figure><h3>Task 3: Add an Options menu item to delete all data</h3><p>In menu_main.xml, change the menu option title and id</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XE6bPKL4uNnyS6wVXeZeuA.png" /></figure><p>In MainActivity, implement the onOptionItemSelected() method to invoke the deleteAll() method on the WordViewModel object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*08UAw2lkGSLa6EzGtAg7ZQ.png" /></figure><h3>Task 4: Delete a single word</h3><p>In WordDao, add the deleteWord() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ic8STMwvU5gB29TD4-CMw.png" /></figure><p>In WordRepository, define another AsynTask called deleteWordAsynTask as an inner class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cn9iT2GoV0_NY6LSOdPIdA.png" /></figure><p>In WordRepository, add the deleteWord() method to invoke the AsynTask you defined</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K3_s3jE2B-ZnM76urFCtQQ.png" /></figure><p>In WordViewModel, add the deleteWord() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KlqwHF4ahBQFPvOB62PMhQ.png" /></figure><h3>Task 5: Enable users to swipe words away</h3><p>In WordlListAdapter, add a method to get the word at a given position</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MEPKPkmWtNKeW4Pq1wTuPw.png" /></figure><p>In MainActivity, in onCreate(), create the ItemTouchHelper. Attach the = ItemTouchHelper to the RecyclerView</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f41fFn54Iq84HIqztJI5hA.png" /></figure><p>onSwiped() gets the position of the ViewHolder that was swiped</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*4gKifQvt_nLGWCbOdSEsww.png" /></figure><p>Given the position, you can get the word displayed by the ViewHolder by calling the getWordAtPosition method that you defined in the adapter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b2dJNwsI5Caprm6-MWERag.png" /></figure><p>Delete the word by calling deleteWord() on the WordViewModel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Slg19PDSCbZjO6xNNxibDA.png" /></figure><p>Run App</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*UXSQ1GPsA8m0k63P49E_dg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*QidXn37NBZcxYk1dVOM6bA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b5560b89fcf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lesson 10 : 10.1 Part A Room, LiveData, and ViewModel]]></title>
            <link>https://medium.com/@nesyavsh31/lesson-10-10-1-part-a-room-livedata-and-viewmodel-422b2826c464?source=rss-646653cb993------2</link>
            <guid isPermaLink="false">https://medium.com/p/422b2826c464</guid>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Nesya Viola]]></dc:creator>
            <pubDate>Thu, 25 Apr 2019 00:21:51 GMT</pubDate>
            <atom:updated>2019-04-25T00:24:40.314Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lesson 10 : 10.1 Part A Room, LiveData, and ViewModel</h3><h3>10.1 Part A Room, LiveData, and ViewModel</h3><p>by Nesya Viola</p><h3>Task 1: Create the RoomWordsSample app</h3><p>Choose basic activity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2uTdAogcZpvwnO3gHxAZGA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VVATlCZWgPo2jdUkroBNUg.png" /></figure><p>Update gradle files</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8r8ZH_LF5-xxUqk1b0-qXw.png" /></figure><p>Add version number in build gradle:project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ebr-L-P4VhraZKsl1cKjw.png" /></figure><h3>Task 2: Create the Word entity</h3><p>Create class Word</p><p>Add a “getter” method called getWord() that returns the word</p><p>Each @Entitiy class represents an entity in a table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UNWQ84kMVf26tzInZPZOeA.png" /></figure><h3>Task 3: Create the DAO</h3><p>Create a new interface and call it WordDao</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V0J2DQfJN5I1M_2MHiBT_w.png" /></figure><p>Annotate the class declaration with @Dao to identify the class as a DAO class for Room</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*9fXouFjuRnv5vXYnP6UXmQ.png" /></figure><p>Declare a method to insert one word</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*l7l3Or-8qSxNDPQlFL1FMA.png" /></figure><p>Declare a method to delete all the words</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*SaAU5325baHx-U_ae-497w.png" /></figure><p>annotate the deleteAll() method with the generic @Query</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*zcSVuDgvPtfZh0N_wCeLhA.png" /></figure><p>Create a method called getAllWords() that returns a List of Words</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*Oo4m6aMVjQ6rTwXY_5OCdQ.png" /></figure><h3>Task 4: Use LiveData</h3><p>In the WordDao interface, change the getAllWords() method signature so that the returned List&lt;Word&gt; is wrapped with LiveData&lt;&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*xMP5xdctK_HKhSwFFFmxKQ.png" /></figure><h3>Task 5: Add a Room database</h3><p>Create a public abstract class that extends RoomDatabase and call it WordRoomDatabase</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*adVYEYDNM5UoqxWg2-tIkw.png" /></figure><p>Annotate the class to be a Room database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LoQJgqZlYvHxcobv8If9Fw.png" /></figure><p>Define the DAOs that work with the database. Provide an abstract “getter” method for each @Dao</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9wABpZYn9rWW6EvVCrFLxA.png" /></figure><p>Create the WordRoomDatabase as a <a href="https://en.wikipedia.org/wiki/Singleton_pattern">singleton</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*bDlDSaDMy6rRp0iYpKTaqQ.png" /></figure><p>Add code to create a database where indicated by the Create Database here comment in the code above</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*zK9i9eLlvmt_6jHbbzHIfA.png" /></figure><p>Add a migration strategy for the database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*8w59eQE1sHc4D8QeS39rdQ.png" /></figure><h3>Task 6: Create the Repository</h3><ol><li>Create a public class called WordRepository.</li><li>Add member variables for the DAO and the list of word</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sQLhTGIuvkBPQcbOc7LHQQ.png" /></figure><p>Add a constructor that gets a handle to the database and initializes the member variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*0T3z0560OlbjouMJ3HchZw.png" /></figure><p>Add a wrapper method called getAllowWords() that returns the cached words as LiveData</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X3l3DKY0GZ4BYns1usf_Zw.png" /></figure><p>Add a wrapper for the insert() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IqYDhxJcfLLiNX66NbIwZw.png" /></figure><p>Create the insertAsyncTask as an inner class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E4CyHvC639jXJ0X28rhAPg.png" /></figure><h3>Task 7: Create the ViewModel</h3><p>Add a private member variable to hold a reference to the Repository</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jiOMDsEKCWdHHev7cwUEKA.png" /></figure><p>Add a private LiveData member variable to cache the list of words</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*uZH9cBEREUi4EaDM_KNLBA.png" /></figure><p>Add a constructor that gets a reference to the WordRepository and gets the list of all words from the WordRepository</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*PtphcxGgpM9lDtQRuqsGHw.png" /></figure><p>Add a “getter” method that gets all the words</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*FQc7MdytWD3gShdvU5-W7A.png" /></figure><p>Create a wrapper insert() method that calls the Repository’s insert() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fPJ4uaSiBs3S5ikB4iXAnA.png" /></figure><h3>Task 8: Add XML layouts for the UI</h3><p>Change the colors in colors.xml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wV19JDJrwbBuQO0dISO3vg.png" /></figure><p>Add a style for text views in the values/styles.xml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R4F7szWMRZkp_OaYQGTrWA.png" /></figure><p>Add a layout/recyclerview_item.xml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pRmfxVpo0A2Q-3UiA_hJhQ.png" /></figure><p>In the content_main.xml file, add a background color to the ConstraintLayout</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*plTo0qdgPNQhocmv0n_hyw.png" /></figure><p>In content_main.xml file, replace the TextView element with a RecyclerView element</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DHRbHZdLZa_CzapMWK0hBg.png" /></figure><p>Fix icon in the FAB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*JRPgkWQ5DTKJesS5XeUeig.png" /></figure><h3>Task 9: Create an Adapter and adding the RecyclerView</h3><p>Add a class WordListAdapter that extends RecyclerView.Adapter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uB7KG8wLn-krzP5Gbr6gUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1LaDk-9Wa0UbCm2tEth_7Q.png" /></figure><p>Add the RecyclerView in the onCreate() method of MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K-NvWXcM0W84hDDDvLGDZQ.png" /></figure><h3>Task 10: Populate the database</h3><p>Add the onOpen() callback in the WordRoomDatabase class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F3Yg9u2SJQShE53dGIZd-Q.png" /></figure><p>Create an inner class PopulateDbAsync that extends AsycTask</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*ho7FAC9-1ZND8lJRaIUOZA.png" /></figure><p>Add the callback to the database build sequence in WordRoomDatabase, right before call .build()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*7eaN5b7rNjQldtzJDc9QbQ.png" /></figure><h3>Task 11: Connect the UI with the data</h3><p>In MainActivity, create a member variable for the <a href="https://developer.android.com/topic/libraries/architecture/viewmodel.html">ViewModel</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iN3Kh-NqfwYE5V8hOlCGKA.png" /></figure><p>In the onCreate() method, get a ViewModel from the ViewModelProviders class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*nAe9yBCxZUdmAjiA2LZnVA.png" /></figure><p>add an observer for the LiveData returned by getAllWords()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DRGwRirvm7MaUG9WpueRaA.png" /></figure><h3>Task 12: Create an Activity for adding words</h3><p>Add these string resources in the Strings.xml file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cVV2AC0hs1XDF9-vHwGzLQ.png" /></figure><p>Add a style for buttons in styles.xml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GQip4IvNHPkumgY9ZcKsiA.png" /></figure><p>Use the Empty Activity template to create a new activity, NewWordActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HSoo5gwGc4S8HtAxcxpGlQ.png" /></figure><p>Update the activity_new_word.xml file in the layout</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Deh19PZsEzsB4ysUp7e9aQ.png" /></figure><p>Implement the NewWordActivity class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IyFPps-FAwMMU-Qskz9Wzw.png" /></figure><p>In MainActivity, add the onActivityResult callback for the NewWordActivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*yLaIb23jMCMey_VE_vZwdg.png" /></figure><p>Define the missing request code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*_1hBb-0Ahey1J0jgAPkfAw.png" /></figure><p>In MainActivity, start NewWordActivit when the user taps the FAB. Replace the code in the FAB’s onClick() click handler</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*6NMy5t1SL2J-FodoZAf5FQ.png" /></figure><p>Run Program</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*zvDiKjrwkkrHJ4uVmyA_xA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*3YhdfYTglTdtnBMPpbRHlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*WZTZQM04xJJbcar_gxUWCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*sXeRfc4bSiyvcEdP0D18aQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=422b2826c464" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10.1B : Menelusuri Database SQLite]]></title>
            <link>https://medium.com/@nesyavsh31/10-1b-menelusuri-database-sqlite-f37d706eacae?source=rss-646653cb993------2</link>
            <guid isPermaLink="false">https://medium.com/p/f37d706eacae</guid>
            <dc:creator><![CDATA[Nesya Viola]]></dc:creator>
            <pubDate>Tue, 02 Apr 2019 00:41:44 GMT</pubDate>
            <atom:updated>2019-04-02T00:41:44.074Z</atom:updated>
            <content:encoded><![CDATA[<h3>10.1B : Menelusuri Database SQLite</h3><p><em>by Nesya Viola S</em></p><h3>Tugas 1 : Tambahkan Penelusuran</h3><p>Unduh WordListSQL yang sudah selesai, lalu pada proyek buat direktori android resource baru dengan nama “menu”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iMnfkvSaOfhW_js6feeEdA.png" /></figure><p>Tambahkan resource pada menu yaitu menu_main.xml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ncGBdfq-vMzketPfdaGHQw.png" /></figure><p>Pada MainActivity tambahkan onCreateOptionsMenu</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*xk9BGRNUoV-6RLFvnSxHrQ.png" /></figure><p>Ganti metode onOptionsItemSelected, Aktifkan action_search dan kembalikan return nilai true</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t5Y32y3MiiTcRawj2MuZPw.png" /></figure><p>Buat salinan activity_edit_word dan beri nama activity_search.xml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W0IXqAyKGBSgs6XmadgDjg.png" /></figure><p>Tambahkan untuk method onClick</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*FSLhFK3iSdx3K3C1Rnfv0w.png" /></figure><p>Tambahkan TextView dengan di search_result, minimal dengan tinggi 300dp dan ukuran font 18sp.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*wR0z-uqgveDZLE-UmcHHQg.png" /></figure><p>Tambahkan activity baru dengan nama SearchActivity. Tambahkan variabel untuk TextView dengan mTextView</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*ZdJaGnXw8bkwI2fL9q9tnQ.png" /></figure><p>Tambahkan variabel EditText dengan mEditWordView</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*YKUeQnyHYMalrovvyirQYg.png" /></figure><p>inisialisasikan mDB dengan WordListOpenHelper(this) yang sebelumnya dibuat dulu variabelnya</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*cMp0-J8Jdz3L_DZUtprMFQ.png" /><figcaption>inisialisasikan juga untuk mTextView dan mEditWordView</figcaption></figure><p>Tambahkan activity ke ke AndroidManifest</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3NTHD2ZN-Sol4L1woEpmLg.png" /></figure><p>Untuk memulai SearchActivity saat item menu dipilih, sisipkan kode untuk memulai SearchActivity ke dalam pernyataan Switch di metode onOptionSelected() di MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*YaLMgIQq8MMgwpylyj-r6A.png" /></figure><p>Implementasikan handler onClick untuk tombol Search di SearchActivity agar tidak crash. Buat fungsi showResult di searchActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zGBNEjfmSowEtfSdf157UQ.png" /></figure><p>Buat variabel String yang bernama word dan inisialisasi dengan mEditWordView</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*ToD1OpSGAXHgaWGYBpqcrQ.png" /></figure><p>untuk mendapatkan cursor</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*zxmPNFGPCBYCgMXtHJdKWw.png" /></figure><p>Implementasikan stub untuk penelusuran di WordListOpenHelper</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mBqL-cL1UtjH0eG_15ryUQ.png" /></figure><p>Langkah terakhir mengimplemenasikan metode penelusuran di WordListOpenHelper</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*z9TSiPE5sp_nWhDFm3aXrQ.png" /></figure><h3>Output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*AeoMsLtaRtamgPzIpZONzA.png" /><figcaption>Pilih menu search</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*gxZgm6yvTg3u0ofttj4CNA.png" /><figcaption>ketikan data yang sudah dibuat yang ingin dicari maka makan menampilkan seperti pada gambar</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f37d706eacae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10.1A : Database SQLite]]></title>
            <link>https://medium.com/@nesyavsh31/10-1a-database-sqlite-6d2ee2e2bb4?source=rss-646653cb993------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d2ee2e2bb4</guid>
            <dc:creator><![CDATA[Nesya Viola]]></dc:creator>
            <pubDate>Tue, 02 Apr 2019 00:05:14 GMT</pubDate>
            <atom:updated>2019-04-02T00:05:14.540Z</atom:updated>
            <content:encoded><![CDATA[<h3>10.1A : Database SQLite</h3><p><em>by Nesya Viola S</em></p><h3>Tugas 1: Memperluas SQLiteOpenHelper untuk membuat dan mengisi database</h3><p>Buka project yang sudah di download sebelumnya lalu buat kelas java WordListOpenHelper</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*FaqTem2_QdD-3mSgwhmxGA.png" /></figure><p>Tambahkan constructor pada WordlListOpenHelper</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*qHWs94Ro-07wmThjldfVNw.png" /></figure><p>Definisikan konstanta untuk tabel, baris, dan kolom</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*96hR8TzKTsn2Lj23runuBQ.png" /></figure><p>Dibawah konstanta tambahkan kode untuk membuat query</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*d0KanFDABL0SA1sFew__UQ.png" /></figure><p>Tambahkan variable instance untuk referensi ke database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*rDaRdHTDxWfwIULhfGxo4w.png" /></figure><p>Dalam method onCreate tambahkan kode untuk membuat database dan tabel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*fOdOexGNY_wXiPMLDOnNYw.png" /></figure><p>Pada MainActivity.java tambahkan variabel instance untuk helper</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*LZ_YNy_lOXdckWeFrJxayg.png" /></figure><p>Pada onCreate inisialisasi mDB dengan sebuah instance WordlListOpenHelper</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*cNXYlEALH0u2rq1MfPzraw.png" /></figure><p>Pada WordlListOpenHelper.java tambahkan panggilan fungsi</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*hgctqt9qsXDLSbnCtoW97g.png" /></figure><p>Selanjutnya implementasikan stub metode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*E_6q2hNQkQ9nq9-O1gl7tQ.png" /></figure><p>Di dalam metod, deklarasikan string kata</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*PzyoGRlQ5ckAD69BVb_jPQ.png" /></figure><p>Buat kontainer data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*l6jz_aHr_feOBMuXVdNWEw.png" /></figure><p>Tambahkan key untuk baris pertama yang disisipkan kedalam database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*BeRyGU0aUii8jhz3Xt_AtQ.png" /></figure><p><strong>point 8 yang clear data</strong></p><h3>Tugas 2: Membuat model data untuk satu kata</h3><p>Buat kelas baru bernama WordItem</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jbMLmMNWLNtHj9p63EuajA.png" /></figure><p>tambahkan variabel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*aU323TVGnea4eM2PXunRtw.png" /></figure><p>tambahkan constructor dan getter setter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d6OH0O-fIBo634dodPbrHQ.png" /></figure><p><strong>Tugas 3. Implementasikan metode query() di WordListOpenHelper</strong></p><p>Buat method query untuk int position pada WordListOpenHelper</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*jqbNaBdfzhCjsjaBaIGTIQ.png" /></figure><p>Buat instance variable cursor</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*9eofCpalfGFvzD4A_l0SFQ.png" /></figure><p>Buat instance entry</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*8vVE4pYOytidWdpb4gTn8A.png" /></figure><p>Tambahkan blok try/catch</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*Vw8TOeyKkjHn2oKwEr4uQg.png" /></figure><h3>Tugas 4 : Menampilkan data di RecyclerView</h3><p>Buka WordListAdapter, dalam onBindViewHolder, tambah code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*5FQ7W6Ly4X8rBu3I1Thyow.png" /></figure><p>Deklarasikan mDB sebagai variabel instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*svleNwBhiTdjhuzfKeRetg.png" /></figure><p>Tetapkan nilai parameter ke mDB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*Wcu8vBvDROlYbjp1uc92ng.png" /></figure><p>Pada MainActivity tambahkan argumen mDB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*vs-PirlvH5r_RcSVa8d5Xg.png" /></figure><h3>Tugas 5. Menambahkan kata baru ke database</h3><p>Pada WordListOpenHelper buat metode insert()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*_oYuFc3y-8MlquPm1p2XhA.png" /></figure><p>Deklarasikan variabel id. Jika operasi insert gagal, metode akan mengembalikan 0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*LGkkXgaXlxKpNxkInZA4dQ.png" /></figure><p>buat nilai ContentValues untuk data baris</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*nA_4-KsNULjfXE4B6TZrlw.png" /></figure><p>Letakkan operasi database Anda ke dalam blok try/catch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*ZjnRbNhDpSXKG_UAlMy1eg.png" /></figure><p>Sisipkan baris</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*ztUFHOvQMeR7N8ONmWLlYw.png" /></figure><p>Periksa untuk memastikan hasil berasal dari aktivitas yang benar</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*YbBqHoyPpdUIpOHMWqHubw.png" /></figure><p>Untuk memperbarui UI, beri tahu adaptor bahwa data yang mendasarinya telah diubah</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*1I5SPLd4ej1EeFZsLSquUg.png" /></figure><p>Jika kata kosong karena pengguna tidak memasukkan apa pun, tampilkan toast yang memberi tahu pengguna</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*Hh35aZOsyK8bLWAkpH0IOw.png" /></figure><p><strong>Implementasikan getItemCount()</strong></p><p>Ubah getItemCount pada WordListAdapter ke kode berikut, yang akan memicu kesalahan</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*rLSbxqroL_0RO5XVtlcD4g.png" /></figure><p>Buka WordListOpenHelper dan implementasikan count() untuk mengembalikan jumlah entri di database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*jD-rVYuKUSM_0AKH5nH5KQ.png" /></figure><h3>Tugas 6 : Menghapus kata dari database</h3><p>Membuat stub metode untuk delete()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*a9hio_g6UFw3jf8wxo5stw.png" /></figure><p>Tambah handler klik ke tombol Delete</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*4Iqu5K4fHtCOiL8kSukZGA.png" /></figure><h3>Tugas 7 : Memperbarui kata di database</h3><p>Tambahkan metode ke WordListOpenHelper menggnakan metode update untuk memperbarui entri yang sudah masuk kedalam database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*RNS_2eMpaojGXNCJ8SMYTg.png" /></figure><p>Tambahkan listener klik ke tombol EDIT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*qF0lQGwdySN7bl_reznZww.png" /></figure><p>Tambahkan pembaruan ke onActivityResult agar dapat dilakukan pembaruan</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*6L1C1y-8AK0sIEhnUQ2W-Q.png" /></figure><h3>Output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*B7CC1C73_1paycYxLmAftw.png" /><figcaption>Ketika menekan floating action button untuk menambahkan list</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*xwfCC9G8DdsdcGcsXAcR-w.png" /><figcaption>Lalu list yang sudah dibuat akan masuk kedalam daftar</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*mVt0dVXx-N1IRSCM5pdPAA.png" /><figcaption>Ketika kita menekan button edit, maka akan kembali ke tampilan ini untuk mengedit data, lalu tekan save</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*TkvQikmAkZMdd3rXLeUpVQ.png" /><figcaption>Ketika kita tekan button delete maka data yang kita buat akan terhapus dari list</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d2ee2e2bb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LESSON 9 : 9.2 App Settings]]></title>
            <link>https://medium.com/@nesyavsh31/lesson-9-9-2-app-settings-ac92e9ecd8b3?source=rss-646653cb993------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac92e9ecd8b3</guid>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Nesya Viola]]></dc:creator>
            <pubDate>Sun, 24 Mar 2019 15:54:27 GMT</pubDate>
            <atom:updated>2019-03-24T15:54:27.105Z</atom:updated>
            <content:encoded><![CDATA[<h3>LESSON 9 : 9.2 App Settings</h3><h3>9.2 App Settings</h3><p><em>by Nesya Viola</em></p><ul><li><strong>Task 1 : Add a switch setting to an app</strong></li></ul><ol><li>Create a new project</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*chWCar9PlZ223OcKJ7Fq4A.png" /></figure><p>2. Run the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*nHOIyBe4VyYqbcM3KgJ67Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*U6Xj3mA2Xa_WjQ1JcW_vbw.png" /></figure><p>3. to create a new resource directory, Select the res directory in the Project &gt; Android pane, and choose File &gt; New &gt; Android Resource Directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3cGsCmORkXU_ZzKzsb04EA.png" /></figure><p>4. In the Resource type drop-down menu, choose xml.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yNewFJK7U_EfeYeY9IJXMw.png" /></figure><p>5. Enter the name of the XML file, preferences, in the File name field, and click OK</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*lontSTAJwH9jLuDfkxDXpQ.png" /></figure><p>6. Add the XML preference and attributes for the setting</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0iKYxdYO_1y0_86DVNCq4A.png" /></figure><p>7. Click the Text tab at the bottom of the layout editor to see the XML code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*cLOcKTLKbN7_yjJrE8gS9Q.png" /></figure><p>8. Use SwitchPreferenceCompat. add the following to the dependencies section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*QJfYxWG4WuJQ29MjhToM_A.png" /></figure><p>9. change &lt;switchPreference in the code to &lt;android.support.v7.preference.SwitchPreferenceCompat</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*aqsdsYnzhSgQBV3x3Pl4zQ.png" /></figure><p>10. Use SwitchPreferenceCompat. Open the styles.xml, and add the following preferenceTheme item to the AppTheme declaration</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*1Z0d16K_UhF4LpoAW9FKWg.png" /></figure><p>11. Add an Activity for settings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MS-3JxDm04gk5H7dbGkjBQ.png" /></figure><p>12. Add a Fragment for a specific setting</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vnhD_JgmjawEQQeQwneIHA.png" /></figure><p>13. he result is the following class definition in SettingFragment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*6JeS5dZC_RrG7QLURwA4Ng.png" /></figure><p>14. Edit the class definition of SettingFragment to extend PreferenceFragmentCompat</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*6v9ssdb9Tm1MUx5kIz4kcQ.png" /></figure><p>15. Add to the newly created onCreatePreferences() stub a call to setPreferencesFromResource()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*lf6xT76Yyfh1dtFigGyB_Q.png" /></figure><p>16. Display the Fragment in SettingsActivity. Add the following code to the end of the onCreate()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*XwsdnOX-QDK3AJtbBuXYcQ.png" /></figure><p>17. Connect the Settings menu item to SettingsActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*gPIevudgdyqM7Ph2l1g5-w.png" /></figure><p>18. Add an Intent to the if block to launch SettingActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*HUMi5R3fRZ86JiESqwi26Q.png" /></figure><p>19. Open AndroidManifest.xml and find the SettingActivity declaration</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*BRrnIYIMe1aZNctBkZSgAA.png" /></figure><p>20. Run the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*8gjkCtNVYUxu5tGbw_mY7g.png" /></figure><p>21. Save the default values in shared preferences. Add the following to the end of the onCretae()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*lzm5wqWjfIMKwbFMkDSMUA.png" /></figure><p>22. Read the changed settings value from shared preferences. Open SettingsActivity and create a static string variable to hold the key for the value</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*2GHuski0R_len2mTVuyzmg.png" /></figure><p>23. Open MainActivity and add the following at end of the onCreate() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*xF0192ocjOhCJA0_CCzHzQ.png" /></figure><p>24. Run the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*8XVfBUwb02HWdKodAd0H1A.png" /><figcaption>Change toggle to off</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*d6xz0BoaTKGQv_exyahMUw.png" /></figure><ul><li><strong>Task 2 : Use the Settings Activity template</strong></li></ul><ol><li>Copy the DroidCafeOptionsUp project folder, and rename it to DroidCafeWithSettings</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1v9rd-aMfMaoseKcVSkCXQ.png" /></figure><p>2. Run the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*F25EQCRs0db35wD58hKUBg.png" /></figure><p>3. Select app at the top of the Project &gt; Android pane, and choose New &gt; Activity &gt; Settings Activity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xDguYml7y8vvKXfixHJ18g.png" /></figure><p>4. Expand DroidCafeWithSettings &gt; app &gt; src &gt; main &gt; java &gt; com.example.android.droidcafeinput and select MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XPWhrqLFsroaWjpyLET4Eg.png" /></figure><p>5. In the Project &gt; Android pane, expand the app &gt; res &gt; xml folder to see the XML files created by the Settings Activity template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*y1Q-ACFZSWUxOKwvdyKZmA.png" /></figure><p>6. Add the Settings menu item and connect it to the activity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*3xcnRn7j9MgY_4HVASE-bw.png" /></figure><p>7. Open MainActivity, and find the switch case block in the onOptionsItemSelected()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*_0Um7LCvIPS-QOawhp5PDA.png" /></figure><p>8. Add a new case for action_setting to the switch_case block with similar Intent code to launch SettingsActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*HCw3n12TMyRObff2aDjz3w.png" /></figure><p>9. Run the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*tkk7hRpWscyKMmtbLEOR7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*QYpXPZhnn0caA_Xn3YrheA.png" /><figcaption>Setting</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*k0kcMZaHnRYL7ArByAnQAQ.png" /><figcaption>General</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*2WPfkMt8c52LhIheDIPa9w.png" /></figure><p>10. Change each value in the pref_market_titles string array to be the titles of markets, such as United States, Canada, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*SfVfS6K_orGPgXM5iCQoSQ.png" /></figure><p>11. Change each value string array (15, 30, 60, etc.) to be values for the markets — abbreviations that correspond to the countries above, such as US, CA, etc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*eiLXtEtIznbXTOJka8tEJQ.png" /></figure><p>12. Open the pref_account.xml file. The ListPreferencfe in this layout defines the setting just have changed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*ceAesA7nx644T3dErK4ibA.png" /></figure><p>13. Change the android:defaultValue attribute to “US”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*Iu4OV7x-0HeT_1S1OyTfiw.png" /></figure><p>14. Add code to set the default values for the settings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*Ea9VS5_PPYPpGfLF0jZY5A.png" /></figure><p>15. Add code to read values for the settings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*GPdOWMisaa_FW0j0uqf82g.png" /></figure><p>16. Run the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*rIaCleU7-YLQe7b_Nc524w.png" /><figcaption>account</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*4tIKobgStJsr8vWkQBUWMQ.png" /></figure><p>17. Run the app again from Android Studio</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*0dJLX8naQrX8DsuwYnvV3A.png" /><figcaption>CA for Canada</figcaption></figure><p>18. Run app on tablet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*noqd3cEO_QYB5ZxXCA9tgg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac92e9ecd8b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LESSON 9 : 9.1 Shared Preferences]]></title>
            <link>https://medium.com/@nesyavsh31/lesson-9-9-1-shared-preferences-90db22f7ab56?source=rss-646653cb993------2</link>
            <guid isPermaLink="false">https://medium.com/p/90db22f7ab56</guid>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Nesya Viola]]></dc:creator>
            <pubDate>Sun, 24 Mar 2019 15:53:12 GMT</pubDate>
            <atom:updated>2019-03-24T15:53:12.362Z</atom:updated>
            <content:encoded><![CDATA[<h3>LESSON 9 : 9.1 Shared Preferences</h3><h3>9.1 Shared Preferences</h3><p><em>by Nesya Viola</em></p><ul><li><strong>Task 1 : Explore HelloSharedPrefs</strong></li></ul><ol><li>Download the <a href="https://github.com/google-developer-training/android-fundamentals-starter-apps-v2/tree/master/HelloSharedPrefs">HelloSharedPrefs-Starte</a> code</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QAbFQTAUY9I9Qm4RpnTcIQ.png" /></figure><p>2. Run the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*WbpYslZ0YHVItjk6cBJfOA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*_qYtSkxWKos6ZtaUUCEiug.png" /><figcaption>when click Count button</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*XLQW5KPMQGwfiKfg9lKuvw.png" /><figcaption>when Click black button</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*1dFrzflvyiNnvK4IWOGvLg.png" /><figcaption>When the device is rotate</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*rGd7PH8m5HaaTpQ0m7-Apg.png" /><figcaption>Reset button to set the color and count back to the defaults</figcaption></figure><ul><li><strong>Task 2: Save and restore data to a shared preferences file</strong></li></ul><ol><li>Add member variables to the MainActivity class to hold the name of the shared preferences file, and a reference to a SharedPreferences object</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*1qVrKr8TOeuvg5AU7YvGqw.png" /></figure><p>2. In the onCretae() method, initialize the shared preferences</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*l68zEYbE2TzXEBpRhWbamQ.png" /></figure><p>3. Add the onPause() lifecycle method to MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*iEf6Bk8n3KmOW0lE06u_Mg.png" /></figure><p>4. In onPause(), get an editor for the SharedPrefrences object</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*zc8T1_-jSFRBWDiGZPrxRA.png" /></figure><p>5. Use the putInt() method to put both the mCount and mColor integers into the shared preferences with the appropriate keys</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*2l3m4uKU8SPb6LmlSHCygw.png" /></figure><p>6. Call apply() to save the preferences</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*JEijcUok2n3DUFAHmMQ6mQ.png" /></figure><p>7. Delete the entire onSaveInstanceState() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*bwUJ2kk9sRl3AhrxmYxOvw.png" /></figure><p>8. In the onCretae() method, in the same spot where the instance state code was, get the count from the preferences with the COUNT_KEY and assign it to the mCount variable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*UNJTcfQUpbBZbz6-5eEWfg.png" /></figure><p>9. Update the value of the main TExtView with the new count</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*Ff-Lvduvl-vNgX4WXTEJ1w.png" /></figure><p>10. Get the color from the preferences with the COLOR_KEY and assign it to the mColor variable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*KS7FUD-NrGPf4HLhJ3DdAg.png" /></figure><p>11. Update the background color of the main text view</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*cGYbog6evVMpfoNqqS8o9Q.png" /></figure><p>12. Run the app, click count button and set background</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*zql12VdCYQeFQ4tXXlf75w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*YjxY6rpCX7pqWS4xsVmc-Q.png" /><figcaption>Rotate the device to verify that the count and color are saved</figcaption></figure><p>13. Reset preferences in the reset() click handler</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*_uF99DlMxwrsKj3zN0fkVw.png" /></figure><p>14. Delete all the shared preferences</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*C2zpBj42eZCkPugcCoaDOQ.png" /></figure><p>15. Apply the changes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*CWriN3ABKWSbv10fcG6FsA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90db22f7ab56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LESSON 8 : 8.3 JobScheduler]]></title>
            <link>https://medium.com/@nesyavsh31/lesson-8-8-3-jobscheduler-2b600ea4c44b?source=rss-646653cb993------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b600ea4c44b</guid>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Nesya Viola]]></dc:creator>
            <pubDate>Sun, 24 Mar 2019 11:22:06 GMT</pubDate>
            <atom:updated>2019-03-24T11:22:06.733Z</atom:updated>
            <content:encoded><![CDATA[<h3>LESSON 8 : 8.3 JobScheduler</h3><h3>8.3 JobScheduler</h3><p><em>by Nesya Viola</em></p><ul><li><strong>Task 1 : Implement a JobService</strong></li></ul><ol><li>Create a new java project “Notificaton Scheduler”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cNL6ZqZj9jCEzJ87-X6oMA.png" /></figure><p>2. register JobService with the following permission</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*jn-lP-2nwVca0pdLim76CA.png" /></figure><p>3. Implement onStartJob(), add image asset to use as notif icon</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*-4pfzpF1P1N3Xd36SaGU8Q.png" /></figure><p>4. Declare a member variable for the notification manager and a constant for the notification channel ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*xWoedbLNTjG1CU2dLG1MEg.png" /></figure><p>5. define a method to create a notification channel. inside the onStartJob()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*CZpmhdlN0lgDMMkguoyv6g.png" /></figure><p>6. Inside onStartJob(), call the method to create the notification channel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*reZbZfoT3B1zfLe92-NLqA.png" /></figure><p>7. Make sure that onStartJob() returns false</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*4r-98tntF4xVJMpNEUY54Q.png" /></figure><ul><li><strong>Task 2 : Implement the job conditions (JobInfo)</strong></li></ul><ol><li>Change the root view element to a vertical LinearLayout</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*aqg9JZ2isewsjF2HbJRc5g.png" /></figure><p>2. Change TextView atribute</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*-i8WBbI1b_bxGRZqPJ2Opw.png" /></figure><p>3. Add a RadioGroup container element and add three RadioButton</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*3rT4_eQvM5qhr-aoFfdJOw.png" /></figure><p>4. Find the RadioGroup by ID and save it in an instance variable called networkOptions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*or6LgWcixrnjpe0TbuuEeg.png" /></figure><p>5. In the scheduleJob() method, get the selected network ID and save it in an integer variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*I7xcGv-lB3EnxZe5-txqSw.png" /></figure><p>6. In the scheduleJob() method, create an integer variable for the selected network option</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*6XoajBXrtOdyqaqGjZyPIA.png" /></figure><p>7. assign the selected network option the appropriate JobInfo network constant</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*DW0ANwqyh3aMrElfHyB_dQ.png" /></figure><p>8. Create a member variable for the JobScheduler</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*wc42J19Yow4aS0xguiYGLw.png" /></figure><p>9. use getSystemService() to initialize mScheduler</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*SpztSIBLsT9XNV33XNnlGg.png" /></figure><p>10. Create a member constant for the JOB_ID, and set it to 0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*pv-w2eIguv1zeWnV0Fn6hQ.png" /></figure><p>11. after the Switch block, create a JobInfo.Builder object</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*oVCAJE2oMVujgflO-xPbfQ.png" /></figure><p>12. Call schedule() on the JobSchedule object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*43GCqpYOp-4KPWqaSFWhYA.png" /></figure><p>13. Show a Toast message, letting the user know the job was scheduled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*lrAstjFtjRpTGdt-hfzW-A.png" /></figure><p>14. In the cancelJobs() method, check whether the JobScheduler object is null</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*qC47R5GYUDTv1wQyPg-V-w.png" /></figure><p>15. Run the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*uZsJeqHrsEMaQeYhXjiT6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*Cf5ELsfP9fGUNtwXOp-FGA.png" /></figure><p>16. Create a boolean variable called constraintSet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*4DdVC6lP-vOiSbfZP33thA.png" /></figure><p>17. If constratintSet is false, show a toast message to the user telling them to set at least one constraint</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*N1VSrRKyKESJfgwOgEzWVA.png" /></figure><p>18. Implement the Device Idle and Device Charging constraints</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*SQV_Yr-suNSkL5zGjLaLTQ.png" /></figure><p>19. Create two switch views as children to the horizontal LinearLayout</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*GXDWSAGhq4VB-Gyf_ur-pw.png" /></figure><p>20. Create member variables called mDeviceIdle and mDeviceCharging</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*mhyU249uwlIiN-W39-flWw.png" /></figure><p>21. In the scheduleJob() method, add the following calls</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*BDtmHQ0W7WbvmHlpx1p57w.png" /></figure><p>22. Update the code that sets constraintSet to consider the new constraints</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*zTniMdyGXY679bWG4pR0Eg.png" /></figure><p>23. Runn app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*Tw3JzQYZ0Kgq2hezVXxemg.png" /></figure><p>24. Below the LinearLayout that has the switch views, create a horizontal LinearLayout</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*4XiSXJaFO32Z48xJZWDLDA.png" /></figure><p>25. Create a member variable for the SeekBar and initialize it in onCreate()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*Zg8EPkqq45IsVoCCh7V9jw.png" /></figure><p>26. In onCretae(), call setOnSeekBarChangeListener() on the seek bar, passing in a new OnSeekBarChangeListener()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*em1B04faDaRaHM4mOtbO1w.png" /></figure><p>27. The second argument of onProgressChanged() is the current value of the seek bar</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*HkiKDpXuNE2UQW3b7UMrFA.png" /></figure><p>28. The override deadline should only be set if the integer value of the SeekBar is greater than 0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*5YdOQ94lh_YJ9-ZAnGHOhQ.png" /></figure><p>29. In the scheduleJob() method after the builder definition, if seekBarSet is true, call setOverrideDeadline() on the JobInfo.Builder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*qXUfwvP6WrjhDhrjUIgBtQ.png" /></figure><p>30. Modify the constrainSet to include the value of seekBarSet as a possible constraint</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*oNh8HGA3O_vxfN2fsXcL3g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b600ea4c44b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LESSON 8 : 8.2 The Alarm Manager]]></title>
            <link>https://medium.com/@nesyavsh31/lesson-8-8-2-the-alarm-manager-3af19bb2ff06?source=rss-646653cb993------2</link>
            <guid isPermaLink="false">https://medium.com/p/3af19bb2ff06</guid>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Nesya Viola]]></dc:creator>
            <pubDate>Sun, 24 Mar 2019 11:20:57 GMT</pubDate>
            <atom:updated>2019-03-24T11:20:57.261Z</atom:updated>
            <content:encoded><![CDATA[<h3>LESSON 8 : 8.2 The Alarm Manager</h3><h3>8.2 The Alarm Manager</h3><p><em>by Nesya Viola</em></p><ul><li><strong>Task 1 : Set up the Stand Up! project and views</strong></li></ul><ol><li>Create new project “Stand Up!” Replace “Hello World” with toogle button</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0f4xCt9Cfboi8H5GYdPGPA.png" /></figure><p>2. Set up the setOnCheckedChangeListener() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*nFv8jx3p7LiuUywKIBZIuQ.png" /></figure><p>3. Call setOnCheckedChangeListener() on the ToogleButton instance, and begin entering “new OnCheckedChangeListener()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*NzC2nT2ncs6ySpaiak3Mgw.png" /></figure><p>4. In the onCheckedChanged() method, set up an if-else block using the boolean parameter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*C7lO7Gqo7Cio5a3hknxxww.png" /></figure><ul><li><strong>Task 2 : Set up the notification</strong></li></ul><ol><li>Create the notification. Create a member variable called mNotificationManager of the type NotificationManager</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*rvr-NtIc9TVFzwaLtLSf7A.png" /></figure><p>2. In the onCretae() method, initialize mNotificationManager using getSystemService()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*PVKHYwMTNyoz3mfhG2ff-Q.png" /></figure><p>3. Create member constants for the notification ID and the notification channel ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*h-f8-QkP3RW7TUYOmoKQWw.png" /></figure><p>4. Create a method called createNotificationChannel() and call et the end of onCretae()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*by8Gh_CiWIlzFDPQM4cbtw.png" /></figure><p>5. Set the notification content Intent</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*A1FpvC7SsqhhlHyFg3QBOA.png" /></figure><p>6. create an Intent that you will use for the notification content intent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*okK7_IG_56oDNk5WQ8hQiw.png" /></figure><p>7. create a PendingIntent from the content intent</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*3ALElifPG2kq7Ku4iyJOUA.png" /></figure><p>8. Use image asset studio to add an image asset to use as the notif icon</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*BqZ-SFZS3Ff871sS0Dz4hA.png" /></figure><p>9. use the NotificationCompat.Builer to build a notification using the notification icon and content intent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*z3nhRvGjQ--jxtTnF0nQfQ.png" /></figure><p>10. At the end of the deliverNotification() method, use the NotificationManager to deliver the notification</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*RZV_FPd-HRYtNTerVhvjxw.png" /></figure><p>11. In onCreate() , call cancelAll() on the Notificationmanager() if the toggle is turned off to remove the notification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*pCMpGqQxx8jqVidevbwzog.png" /></figure><p>12. Run the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*9NY_9-yp5_Nn0viNRQLb7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*8t-Fif9xJDB4Y3ffW8xFwA.png" /></figure><ul><li><strong>Task 3 : Create the repeating alarm</strong></li></ul><ol><li>Set the repeating alarm</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*g_6Kl0iKslLUPEDZmbI4aw.png" /></figure><p>2. call setInextactRepeating() on the alarm manager instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*SlzLLA8rF7k7k9qRKdTkFw.png" /></figure><p>3. The PendingIntent to be delivered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*PyMqXQn7xXRsPD1MuEkqdQ.png" /></figure><p>4. cancel the alarm by calling cancel() on the AlarmManager</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*o18v1dioS_AcYY9vUoLksw.png" /></figure><p>5. Run the app</p><p>6. Check the state of the alarm. Create a boolean that is true if PendingIntent is not null, and false otherwise</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*trgIxvmO1mxK0L-sUmk8mg.png" /></figure><p>7. Set the state of the toggle right after you define alarmUp</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*v_q7q61bfwpSGi-EqJ9miQ.png" /></figure><p>8. Set the state of the toggle right after you define alarmUp</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*0yfk1nxtA5EOLkVjyM1KrQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3af19bb2ff06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LESSON 8 : 8.1 Notifications]]></title>
            <link>https://medium.com/@nesyavsh31/lesson-8-8-1-notifications-1916a68355cb?source=rss-646653cb993------2</link>
            <guid isPermaLink="false">https://medium.com/p/1916a68355cb</guid>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Nesya Viola]]></dc:creator>
            <pubDate>Sun, 24 Mar 2019 11:19:36 GMT</pubDate>
            <atom:updated>2019-03-24T11:19:36.667Z</atom:updated>
            <content:encoded><![CDATA[<h3>LESSON 8 : 8.1 Notifications</h3><h3>8.1 Notifications</h3><p><em>by Nesya Viola</em></p><ul><li><strong>Task 1 : Create a basic notification</strong></li></ul><ol><li>Create the prohect “NotifyMe”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E-XEAZEhPFPGsc44WKqy5Q.png" /></figure><p>2. Replace the default TextView with a button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*cx7QucI13wPtE4eIEBKtFQ.png" /></figure><p>3. Create a member variable for the Notify Me button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*TlKuSrwCgcq8L36ablGZPA.png" /></figure><p>4. Create a method stub for the sendNotification() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*CyIpkO8MuBMRmUQS2-AeOA.png" /></figure><p>5. In the onCreate() method, initialize the Notify Me! button and create an onClickListener</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*Xz75HGb6acq50WytRNrnDw.png" /></figure><p>6. Create a notification channel. In MainActivity, create a constant for the notification channel ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*WRoWn8w7iO4MDVWC2gUYbA.png" /></figure><p>7. create a member variable to store the NotificationManager object</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*KWmRooGzhx6GwYFL5ArtYA.png" /></figure><p>8. Create a notification channel in the createNotificationChannel() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*ydRVtrtES7abRtp06CO20g.png" /></figure><p>9. Set the importance to IMPORTANCE HIGH</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*rFiRKFQ_XXNld9ZRnU4ApA.png" /></figure><p>10. configure the notificationChannel() object’s initial settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*QinHMKs6sSbNtiPlwfplaw.png" /></figure><p>11. Build your first notification. go to File &gt; New &gt; Image Asset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*yLYagjF3nVOyxfUvCGQqcw.png" /></figure><p>12. To build notification and display it, In MainActivity, create a constant for the notification ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*i8k6BR6dJ3TxlI-me0gflQ.png" /></figure><p>13. at the end of the onCreate() method, call createNotificationChannel()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*y7qYHKNQnk1vsrQs_h5EiA.png" /></figure><p>14. create a helper method called getNotificationBuilder()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*-0nK-BlW26UjGTBhIG0M0A.png" /></figure><p>15. create and instantiate the notification builder inside the getNotificationBuilder()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*Z0WxjkMUtAgr6inet-N8qQ.png" /></figure><p>16. add the title, text, and icon to the builder,inside getNotificationBuilder()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*Si1K8WJa_RO14Ia0IX2kHA.png" /></figure><p>17. In MainActivity inside the sendNotification method, use getNotificationBuilder() to get the Builder object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*V-dV3tqtkaU3Y5JD-PBgQA.png" /></figure><p>18. Call notify() on the NotificationManager</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*HuLj96S9wDlD4ZbziiCywA.png" /></figure><p>19. Run the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*WNcHqf-vaZiRmtpKonpKYA.png" /></figure><p>20. Add a content intent and dismiss the notification. create an explicit intent method to launch the MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*Yt78EwRW7FxTqq-LCHfn-A.png" /></figure><p>21. use the getActivity() method to get a PendingIntent</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*eBwb5nnonbaD7FaJq442PA.png" /></figure><p>22. Use the setContentIntent() method from the NotificationCompat.Builder class to set the content intent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*N05ZH4rXeOQu_34x7pQzHw.png" /></figure><p>23. Run the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*2SU7J4nhNo0GORyLrz1hKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*AH-XSoYI28mzssqD5Hrx3A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*6mlUDIte6VknUKpzw5nVgA.png" /></figure><p>24. Inside the getNotificationBuilder() method, set the priority of the notification to HIGH</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*z3jQF3gAE-jmHV8woQBjcw.png" /></figure><p>25. Set the sound, vibration, and LED-color pattern for your notification</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*C_2MAC14k5opCuktCoHI5w.png" /></figure><ul><li><strong>Task 2 : Update or cancel the notification</strong></li></ul><ol><li>Create 2 copies of NotifyMe button in activity_main.xml</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*jJChO9wO3zIUO0-Mje9thg.png" /></figure><p>2. Change android:text in the new buttons to “Update Me!” and “Cancel Me!”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*ZXo_tPPtwxDWXVgMv0Uzeg.png" /></figure><p>3. Add a member variable for each of the new buttons</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*1cEkDgLffLkm0bv1ykqKSA.png" /></figure><p>4. At the end of onCretae() method, initialize the button variables and set their onClick listeners.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*ZML_gu9VgOzqoMBwR4Fj8w.png" /></figure><p>5. Create methods for updating and canceling the notification</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*R-WytXp63rNypxdqQV3N1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*3PshibYb7VUGlsc4L4xS4A.png" /></figure><p>6. In the onCreate() method, call updateNotification() in the update button’s onClick() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*4l5yAnlxGA5RK7ruubNeoQ.png" /></figure><p>7. Implement the cancel and update notification methods. Add the following line in MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*Z6vM2RkWJDryDTi0pCSHyg.png" /></figure><p>8. Run the app, tap Notify Me! button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*P5sEzgx03Ps_yGGOfWz6yw.png" /></figure><p>9. Tap the Cancel Me! button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*UAWY014ub5FQl8sCTwZ7UA.png" /></figure><p>10. Download image to use in notification, put in drawable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/1*q02IuOcLOBSez8603fvLGg.png" /></figure><p>11. In MainActivity, inside the updateNotification() method, convert your drawable into a bitmap</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*WWOe2cdDWW1axInNziR0Aw.png" /></figure><p>12. nside updateNotification(), use the getNotificationBuilder() method to get the NotificationCompat.Builder object</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*ER8z9JZXTFjK7N_6B1lbZA.png" /></figure><p>13. change the style of notification and set the image and the title</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*-QAFHOGs6wyviTeD55lfUw.png" /></figure><p>14. build the notification and call notify() on the Notificationmanager</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*Y1fYhJtiN_wdApGhyIVnCw.png" /></figure><p>15. Add a utility method called setNotificationButtonState() to toggle the button states</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*KKjCxhWaD2Z0plZ0bzRhUA.png" /></figure><p>16. add a call to setNotificationButtonState() to enable and disable the buttons</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*U6SsYqG6lwbqAWhedjFTbQ.png" /><figcaption>onCreate()</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*wRVwjR-rDkhdNveODF9GTw.png" /><figcaption>sendNotification()</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*eqg1xePIAFxYxDeu0ERTow.png" /><figcaption>updateNotification()</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*iYDw_oj7ZIuoKl1ZgNFaBg.png" /><figcaption>cancelotification()</figcaption></figure><ul><li><strong>Task 3 : Add a notification action button</strong></li></ul><ol><li>add a subclass of BroadcastReceiver as an inner class in MainActivity</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*gyxgpajzokLk053heWYVEw.png" /></figure><p>2. call UpdateNotification()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*DJH-QPG05vVq_sWyZGlHiQ.png" /></figure><p>3. create a unique constant member variable to represent the update notification action in MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*sg33VK_x0_pu8yqe1fUeXg.png" /></figure><p>4. create a member variable for receiver and initialize it using the default constructor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*thLGXYx1P_XskpevDPs5_g.png" /></figure><p>5. To receive the ACTION_UPDATE_NOTIFICATION intent, register broadcast receiver in the onCreate() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*GE0K_Ld3J1PBDpND6cC5zg.png" /></figure><p>6. To unregister receiver, override the onDestroy() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*UYv1X2WaTw1l8pgPWZZgaQ.png" /></figure><p>7. Create an icon for the update action</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*7WsSmHbkfFBMUJ4JIXUm3A.png" /></figure><p>8. create an Intent using the custom update action ACTION_UPDATE_NOTIFICATION</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*sTJA1Rg_yq8WOTeecUq9lw.png" /></figure><p>9. Use the addAction() method to add an action to the NotificationCompat.Builder object</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*x5oJAQ3WlU_2bV1Ui0RFnQ.png" /></figure><p>10. Run app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*aIkJxJ8W5GV5PyzoeQO6DQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1916a68355cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Firebase Android Codelab]]></title>
            <link>https://medium.com/@nesyavsh31/firebase-android-codelab-5e4591cc5e6b?source=rss-646653cb993------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e4591cc5e6b</guid>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Nesya Viola]]></dc:creator>
            <pubDate>Sun, 17 Mar 2019 17:20:51 GMT</pubDate>
            <atom:updated>2019-04-01T16:20:55.142Z</atom:updated>
            <content:encoded><![CDATA[<h3>Firebase Android Codelab</h3><p><em>by Nesya Viola</em></p><ul><li><strong>Step 1 : Overview</strong></li></ul><p>Update Android Studio version</p><ul><li><strong>Step 2 : Get the sample code</strong></li></ul><p>Clone project at link based on the website</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*uKO7o4t_M19NBN9qFiB4rQ.png" /></figure><p>The projects contains three directories <strong>android-start, android</strong>, <strong>grow-android-start</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*7hjIc_iw9aRMhQRC9uimtQ.png" /></figure><ul><li><strong>Step 3 : Import the starter app</strong></li></ul><p>Import android-start directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*sBGv8ifb4CWW8M5KaaCGFg.png" /></figure><ul><li><strong>Step 4 : Create Firebase console Project</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQT-GEEEQIufaAfbYGqPhA.png" /></figure><ul><li><strong>step 5 : Run the starter app</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*xJTY70ipK5PXwxKblJ3rkg.png" /></figure><ul><li><strong>step 6 : Enable Authentication</strong></li></ul><p>select the <strong>Rules</strong> tab and update the rules configuration</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*dIFFjBWjLq-O_ot8wSHgDg.png" /></figure><p>Navigate to the <a href="http://console.firebase.google.com/">Firebase console</a> and select your project &gt; Select <strong>Authentication</strong> &gt; Select the <strong>Sign In Method</strong> tab &gt; Toggle the <strong>Google</strong> switch to enabled (blue) &gt; Press <strong>Save</strong> on the resulting dialog</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*V-DNhi5e-iWM-NaVb-xp5Q.png" /></figure><p>Add Firebase Auth dependency</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*h3ovYsNLwUSj69r7p9tXVw.png" /></figure><p>Add the Auth instance variables in the MainActivity class:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*Sab3oYqmdsVuqhI7ICGXvA.png" /></figure><p>Add the following to the onCreate method <strong>after </strong>mUsername has been initialized</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*I0ulfJa2SoXS43hObU79-w.png" /></figure><p>add a new case to onOptionsItemSelected() to handle the sign out button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*Rc0Uo6Qb5nBE-eVrVZmTeQ.png" /></figure><p>Add an Auth instance variable in the SignInActivity class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*98twZ5F035PDkAEl83iHrA.png" /></figure><p>edit the onCreate() method to initialize Firebase in the same way you did in MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*mYGAX_zLAS0-M3Oztmgwyg.png" /></figure><p>initiate signing in with Google. Update SignInActivity&#39;s onClick method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*qaMH4fmGM7VzvvO3ESgYOA.png" /></figure><p>Add the required signIn method that actually presents the user with the Google Sign-In UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*bOxIZKyjNLj0aVurfs5zNA.png" /></figure><p>add the onActivityResult method to SignInActivity to handle the sign in result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*FdhyX35nAXwr5zNe3Ryt_Q.png" /></figure><p>Add the required firebaseAuthWithGoogle method to authenticate with the signed in Google account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*kxzuLHVDTryTDQYAiONyUw.png" /></figure><p>Test the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*6Y5lL261PQvB8WMU0pbUmw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*ycmJwV3f8iq56pgIXsn6PA.png" /></figure><p><strong>Step 7 : Read Messages</strong></p><p>In your project in Firebase console, select <strong>Database</strong> on the left navigation menu</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*1EAGqhVHDDyhT21UfOP8IA.png" /></figure><p>In the overflow menu of the Database, select <strong>Import JSON</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*SEz-TVtkIrwM3INeMFpjRA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*_sazvtz3wX1L-ZG4rkFLLQ.png" /></figure><p>Adding the Database instance variables in the MainActivity class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*j3XdcKnM-IVpaNHDoiSMTw.png" /></figure><p>Modify your MainActivity’s onCreate method by replacing <em>mProgressBar.setVisibility(ProgressBar.INVISIBLE); </em>with the code defined below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*nlgOuAHHhFP0mu6bUeyj0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*1-FTckIxgK39uw4K6prT-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*mpxS-GMB3HRJ6FhNxhoA-w.png" /></figure><p>Update the <em>onPause</em> and <em>onResume</em> methods in MainActivity as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*53G8HttkogYujf6Ml6st9g.png" /></figure><p><strong>Step 8 : Send Messages</strong></p><p>Update the onClick method of mSendButton in the onCreate method in the MainActivity class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*hkz2ygaTMy2aCX3UoMVp9g.png" /></figure><p>Update the onClick method of mAddMessageImageView in the onCreate method in the MainActivity class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*MB5dKXdXp7FRsr7GIBqs5w.png" /></figure><p>add the onActivityResult method to MainActivity. write a message with a temporary image url to the database indicating the image is being uploaded</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*-R6eLtG6EuOm9V8wxVZd2g.png" /></figure><p>Add the method putImageInStorage to MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*vizlcYv96y0N-3PPymSwTg.png" /></figure><p>Run app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*t2RSMQlwUK8NwHeNmMCJxg.png" /></figure><p><strong>Step 9 : Add Messages to the On-device Index</strong></p><p>Add an intent filter into AndroidManifest.xml file to handle incoming links of the form <a href="http://friendlychat.firebase.google.com/message/*">http://friendlychat.firebase.google.com/message/*</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*CxoehrVLsi0PF63AOCVxxA.png" /></figure><p>add the following code to create a message to write to the on-device index</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*abB8Z3N15NhwYLkDkAjbtA.png" /></figure><p>Call indexMessage() whenever there is a new message</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*ZfPXnb51S0UJWZVD70TKfQ.png" /></figure><p>To log the VIEW_ACTION user action, add the following function to MainActivity.java</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*KUdxVVZ6wL3DkIg3F8G8iA.png" /></figure><p>add the FirebaseUserActions.getInstance().end(...) method to indicate the end of logging a user action</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*ZSp8CpHx8GvvbTLfJQQIOA.png" /></figure><p>Test the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*c9v3grtkBj_pBx2NwDqvsQ.png" /></figure><ul><li><strong>Step 10 :</strong> <strong>Receive Re-engagement Notifications</strong></li></ul><p>can override the onMessageReceived method from the FirebaseMessagingService base class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*mQrJycmdwH7TSOpxa6LDyA.png" /></figure><p>Modify it to extend FirebaseInstanceIdService and override the onTokenRefresh method to subscribe to a topic</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*suLeQIQO8g2Ixd0Vm0aBGg.png" /></figure><p>Add service declarations for the MyFirebaseMessagingService and the MyFirebaseInstanceIdService as children of the application element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*SGbUPXMyZOhyj1zZ7bBHhA.png" /></figure><p>In Firebase console select Cloud Messaging from the Grow section of the left navigation bar. Select Send Your First Message</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K143GoxMjriUnm3KzfU2wA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NdZv88EDMoNypcUGshTGdQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dKrSNerN-9VL4LQiKHrRZQ.png" /></figure><p>Test the app</p><ul><li><strong>Step 11 : Remotely Configure Friendly Message Length</strong></li></ul><p>In the Remote Config section of Firebase console click Add Your First Parameter. Set the parameter key to friendly_msg_length and the parameter value to 10</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V4zq6rfSpeNQ_s6bzR-w7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJ4COe9VkwvzJo1WG2ORHA.png" /></figure><p>Add Firebase Remote Config dependency</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*VkWYsJsecZ_wPyZ7Y1NR2g.png" /></figure><p>Add a Firebase Remote Config instance variable in the MainActivity class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*l0hE8DWebA6MIsDL6J-dPQ.png" /></figure><p>In the MainActivity onCreate method, add the following snippet to initialize the FirebaseRemoteConfig and then invoke the fetchConfig method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*ahCFIzDD-OSNhuhQ-buRqA.png" /></figure><p>Add fetchConfig and applyRetrievedLengthLimit methods to MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oHBaRHHYlUbOKL7Ldwmugw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8OmtUQrlDPfB15IMOEUrYg.png" /></figure><p>Add a call to fetchConfig in the onOptionsItemSelected method in MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*nHqWNMRoutdaYUFbnMsKxg.png" /></figure><p>Test Config</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*8I8DCzAxYrsVQIuMTlniHg.png" /><figcaption>parameter dengan nilai default 10</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BfiENaA68wzaGoY9DTzfUw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/1*fJwxUOoW8L7vwz1ek6_maQ.png" /><figcaption>parameter dengan nilai default 20</figcaption></figure><ul><li><strong>Step 12 : Send Install Invites</strong></li></ul><p>Add AppInvite dependency</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*IKZDg4aWt7jQkuWZIDWB1A.png" /></figure><p>Setup GoogleApiClient</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*Tgf-jeA1JQkPXp-rvj0M4w.png" /></figure><p>Confirm that the required onConnectionFailed method is implemented</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*Vr-nUDRG_ttlkfvIqt59Kw.png" /></figure><p>Update the GoogleApiClient initialization in the onCreate method of MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*MKe6aczyVREhmwnVDYvIcA.png" /></figure><p>Add the sendInvitation method to MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*vKIKpjk_E9mH41NeI69lBQ.png" /></figure><p>Update the onActivityResult method in MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R5wlcYX7o0D9YzGbx_r2EQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CeV2G20PDBpzeggSZ9Ggiw.png" /></figure><p>Add a call to sendInvitation to the onOptionsItemSelected method in MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*kxZBvmTbRf0yorbv3Y2RYg.png" /></figure><p>Test App Invite</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*IQfOM0mpp5elEpVJvm8Org.png" /><figcaption>choose invite</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*27chXYhroPqdB2NX3uwQTA.png" /><figcaption>choose account</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*xd5gNH9Y95dcMtkuCNFx3Q.png" /><figcaption>choose who want to invite</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*CDnKQaRg7r5UmZO7wym7zg.png" /><figcaption>Notification will appear</figcaption></figure><ul><li><strong>Step 13 : rack User Flows</strong></li></ul><p>Add Analytics dependency</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*lnKjQP4qdK2BYxp5n8vVvA.png" /></figure><p>Initialize Analytics</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*nWAquKIPsq4C0DSwyf8xFQ.png" /></figure><p>In MainActivity initialize mFirebaseAnalytics by adding the following line to the onCreate method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*QlZu7FN6VG8Tye4XUjYw0Q.png" /></figure><p>Send Custom Events</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*93bZTp8Z6zUH9kB5Cj5u1g.png" /></figure><ul><li><strong>Step 14 : Monetize with Ads</strong></li></ul><p>Add AdMob dependency</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*aPX_IlMwoZ9kUDOoWkXdNA.png" /><figcaption>Add ads namespace</figcaption></figure><p>Add ads namespace</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*fGr596mBZDfKvQvy3Px4AA.png" /></figure><p>Add AdView to main layout</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*MN8XhBMHX2yLhf_7dsRl3w.png" /></figure><p>Add AdView variable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*qMCsGozKLapRiGUeE_YhMw.png" /></figure><p>Request Ad</p><p>In MainActivity in the onCreate method, request the ad to be placed in the AdView</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*IeZaLTHFmwFEAzR0MaVZJQ.png" /></figure><p>Handle lifecycle events</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*dq8OQ892mbVrJ-wGSQz9GQ.png" /></figure><p>Run app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*1bvjjxotordb_xOgqzMoXw.png" /></figure><ul><li><strong>Step 15 : Report Crashes</strong></li></ul><p>Add Firebase Crashlytics dependency</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2xlIMAzjdln00-_q4T2KCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*i7Ak2790aSSYmHVBtetHmA.png" /></figure><p>Initiate crash. Update the onOptionsItemSelected method in MainActivity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*y-aggadjBQKDqjZ9iJSXZw.png" /></figure><p>Add causeCrash method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*6Ququl67ZBm53TSLbLGn9g.png" /></figure><p><strong>Test Firebase Crashlytics</strong></p><p>To activate the app with Firebase Crashlytics, go to the Firebase Dashboard and click ‘Crashlytics’, select ‘Yes, this app is new to Crashlytics.’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1XMB87U-xoeaG5d61LMM3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i5H7lq162INI3vM7oaRvcA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e4591cc5e6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>