<?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 Navin Kumar on Medium]]></title>
        <description><![CDATA[Stories by Navin Kumar on Medium]]></description>
        <link>https://medium.com/@navinkumar0118?source=rss-baa46aff279------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eNaJkun9eXLaocWSv5iJHg.png</url>
            <title>Stories by Navin Kumar on Medium</title>
            <link>https://medium.com/@navinkumar0118?source=rss-baa46aff279------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 29 May 2026 17:55:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@navinkumar0118/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[How Android Renders the UI]]></title>
            <link>https://navinkumar0118.medium.com/how-android-renders-the-ui-f8574b2d31ab?source=rss-baa46aff279------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8574b2d31ab</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-memory-management]]></category>
            <dc:creator><![CDATA[Navin Kumar]]></dc:creator>
            <pubDate>Mon, 06 Nov 2023 19:39:40 GMT</pubDate>
            <atom:updated>2023-11-06T19:39:40.364Z</atom:updated>
            <content:encoded><![CDATA[<p>Don&#39;t start to code, until u know this…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZRBN6zOo3a0TI9rzKLD1tQ.png" /></figure><h3>Intro</h3><p>This blog explains how the Android memory management system functions, how UI is rendered, Garbage collector, and how the application’s performance can be improved.</p><p>Similar to how most developers avoid learning about this topic, so do I. Of course. After reading this blog, you’ll surely understand this concept very clearly.</p><p>Are you excited, Lets dive…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*D3McQCn2faR7geD1PoeNjA.gif" /></figure><h3>How Android renders UI on Screen (Main Thread)</h3><p>Before getting started with memory management, first we have to know how Android renders the UI on screens in each frame.</p><ul><li><strong><em>Yes, Android will draw the UI every 16 milliseconds (ms). 📱</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wsbSRDZBcs6e-bT6wb7rOg.png" /></figure><h4><strong>(</strong><strong>60FPS -&gt; 1000ms/60 = 16.67ms ~ 16ms)</strong></h4><ul><li>Android will render UI in 60FPS, which means the UI will be updated every 16.67 milliseconds. ~roundly<strong> (16 ms)</strong></li><li>Any operation or logic will have to be completed within 16ms so that it can be updated to the UI smoothly.</li><li>If a task takes more than 16ms on the main thread, leads to a frame drop and the app will be lagged.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nMgg3HTDOH-0aQ-txwIkJA.png" /></figure><ul><li>In the above example,<strong> Task 1 </strong>has been executed within 16ms. So it can be easily rendered on UI smoothly.</li><li><strong>Task 2, </strong>takes 24ms to be executed. So after every 16ms android needs to update the UI. But in this case, still waiting for the task completion.</li><li>This leads to <strong>Frame drop</strong>, 3rd frame will be dropped and the app will freeze until the next frame is drawn.</li><li>The UI is rendered after 32ms.</li></ul><blockquote>So keep in mind, Its “16ms” and it has to be within “16ms”.</blockquote><ul><li>Now you know that every task has to be done within 16ms for better rendering performance.</li><li>If any app lags, now you know why and how.</li></ul><h3>Why the App Freezes?</h3><blockquote>1) Task or logic has not been completed within 16ms.</blockquote><blockquote>2) Doing the heavy task on Main Thread.</blockquote><blockquote>3) Too many processes from the Garbage Collector.</blockquote><p>You could be thinking, “Yeah, I know the garbage collector.” But how?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*msbOIxVRvXwc5bG9-PNcHQ.gif" /></figure><h3>️Garbage Collector 🗑 (GC)</h3><p>The Garbage collector, will scan all the memory blocks and find the unused memory, then clears the memory for reallocation to the heap.</p><p>It collects garbage (unused objects/memory/data) from the allocated memory and frees up this unused space.</p><blockquote>The mechanism for reclaiming unused memory within a managed memory environment is known as garbage collection.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v6Ysr3RuVk3dTH5gP3vhMg.png" /></figure><ul><li>Now u wonder, WOW GC is doing a great job!</li><li>But you are a quality developer, right? then why does your junk code have unused memory?</li><li>This leads GC to run frequently on the main thread, which again increases the<strong> task execution time &gt; 16ms.</strong></li><li>Now you know why GC impacts APP performance. The time GC runs, the actual app is not running.</li><li>As a developer, make sure all your allocated objects have been used wisely. 🤞 and avoid frequent GC calls.</li></ul><h3>Choreographer (bonus topic)</h3><ul><li>It is a class, responsible for drawing the ui frames every 16ms on the main thread.</li><li>With the help of <strong>choreographer, </strong>we can verify our application tasks have been executed within all frame limits.</li></ul><blockquote><strong>choreographer: </strong>coordinates the timing of animations, input and drawing.</blockquote><h3>Conclusion</h3><p>Wow great 🎉 I hope this blog is helpful in understanding the android rendering and memory concepts. I’m passionate about helping fellow developers and entrepreneurs succeed and I can’t wait to share my knowledge with you all.</p><blockquote>This article helped you? Long press on the 👏 button as long as you can.</blockquote><blockquote>I got something wrong? Mention it in the comments. I would love to improve.</blockquote><blockquote>I am NavinKumar, Lead Application developer @IBM. You can find me on <a href="https://www.linkedin.com/in/navin-kumar/">Linkedin</a> or stalk me on <a href="https://github.com/navinkumar0118">GitHub</a> or Follow me on <a href="https://medium.com/@navinkumar0118">Medium</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8574b2d31ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding App Store listing guideline]]></title>
            <link>https://navinkumar0118.medium.com/app-store-listing-guideline-a7ac1ff75aa9?source=rss-baa46aff279------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7ac1ff75aa9</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[app-store]]></category>
            <dc:creator><![CDATA[Navin Kumar]]></dc:creator>
            <pubDate>Tue, 10 Oct 2023 10:14:00 GMT</pubDate>
            <atom:updated>2023-10-10T13:27:12.961Z</atom:updated>
            <content:encoded><![CDATA[<p>The simplest way to understand Apple’s app store listing…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sDNZlhz3FwIjyaF35oqZzg.jpeg" /></figure><h3>Intro</h3><p>In this blog, we will see what steps and guidelines need to be followed while publishing an application on Apple’s App Store.</p><p>To publish an app on AppStore requires an <strong>Apple</strong> <strong>developer account</strong>. To create a new account please go to <a href="https://developer.apple.com/sign-in-with-apple/">https://developer.apple.com/sign-in-with-apple/</a>.</p><p>Kindly follow the below steps to meet the app store guidelines.</p><p><strong>Here are a few topics I’ll be covering in my blog:</strong></p><p>📌 Key Principles of the App Store Review Guidelines</p><p>📌 Tips for creating apps that adhere to Apple’s standards</p><p>📌 Common pitfalls to avoid during the app submission process</p><p>📌 Updates on recent changes and announcements from Apple</p><p><strong>Table contents:</strong></p><ol><li><em>App Name</em></li><li><em>App Icon</em></li><li><em>Subtitle</em></li><li><em>App Previews (Optional)</em></li><li><em>Screenshots</em></li><li><em>Description</em></li><li><em>Promotional Text</em></li><li><em>Keywords</em></li><li><em>In-App Purchases (Optional)</em></li><li><em>What’s New (Not for the first release)</em></li><li><em>Ratings and reviews</em></li><li><em>Categories</em></li><li><em>Localization (Optional)</em></li><li><em>Support URL</em></li><li><em>Marketing URL</em></li><li><em>App Privacy policy URL</em></li><li><em>App Review Information</em></li><li><em>Authentication Details (Dev team will do)</em></li><li><em>Attachment (Optional)</em></li><li><em>Other Params</em></li></ol><h3><strong>1. App Name</strong></h3><p>Your app’s name appears at the top of your app listing and is limited to 30 characters. Your app name can be longer than the relatively limited text beneath your app’s icon on a user’s home screen.</p><p><strong>According to Apple’s recommendations, the app name should:</strong></p><ul><li>Be simple, catchy, compelling, and easy to understand</li><li>Communicate the key purpose of your app</li><li>Be up to 30 characters long,</li><li>Differ from competitors’ app names,</li><li>Exclude generic terms, popular app titles, special characters (e.g. #, @), prices, celebrity names, trademarked terms, and other protected words.</li></ul><h3><strong>2. App Icon</strong></h3><p>Many elements go into an app’s icon during the app design process to make sure it’s memorable. Work with your app development partner or review <a href="https://developer.apple.com/design/human-interface-guidelines/guidelines/overview/">Apple’s Human Interface Guidelines</a> to help you guide your icon’s design.</p><p><strong>Below you can find size requirements for icons on the App Store:</strong></p><h4><strong>iPhone:</strong></h4><blockquote>180px × 180px (60pt × 60pt @3x)</blockquote><blockquote>120px × 120px (60pt × 60pt @2x)</blockquote><blockquote><strong>iPad Pro:</strong></blockquote><blockquote>167px × 167px (83.5pt × 83.5pt @2x)</blockquote><blockquote><strong>iPad, iPad Mini:</strong></blockquote><blockquote>152px × 152px (76pt × 76pt @2x)</blockquote><h4><strong>App Store:</strong></h4><blockquote>1024px × 1024px (1024pt × 1024pt @1x)</blockquote><p><strong>To be eligible for the App Store, icons have to meet the following specifications:</strong></p><ul><li>Format: PNG</li><li>Color space: sRGB or P3 (see Color Management)</li><li>Layers: flattened with no transparency</li><li>Resolution: varies. See Image Size and Resolution</li><li>Shape: square with no rounded corners</li></ul><h3>3. Subtitle</h3><p>Your app’s subtitle is intended to summarize your app in a concise phrase. Consider using this, rather than your app’s name, to explain the value of your app in greater detail.</p><p><strong>Here are the App Store requirements for the subtitle:</strong></p><ul><li>It should be compelling to encourage users to explore your product page and download your app</li><li>It should be limited to 30 characters</li><li>It shouldn’t include generic descriptions, for example, “world’s best app.” The title and subtitle together provide 60 characters for you to get through to your users. Focus on your distinctive features or typical uses;</li><li>Subtitles have to comply with the App Store’s standard metadata rules. Avoid misleading or false product claims or inappropriate content, and never exploit competitors’ apps by any means.</li></ul><h3><strong>4. App Previews </strong>(Optional)</h3><p>An app preview demonstrates the features, functionality, and UI of your app in a <strong>short video</strong> that users watch directly on the App Store. Previews can be up to 30 seconds long and use footage captured on the device to show the experience of using your app. You can feature up to three app previews on your App Store and Mac App Store product pages, and localize them for all available App Store languages. <a href="https://help.apple.com/app-store-connect/#/dev910472ff2">Know more</a></p><p><strong>Here are some recommendations by Apple to create effective app previews:</strong></p><ul><li>Use the footage of the app in use, enhanced by graphic elements, textual or video overlays, and narration, if the video requires additional explanation. Avoid using animated hands gesturing or real people navigating the device, as well as the caption of your app’s development.</li><li>Since previews autoplay, it’s recommendable to make the first few seconds visually engaging. When the videos don’t autoplay, users see poster frames, which should also communicate the essence of the app. Learn how to set a poster frame <a href="https://help.apple.com/app-store-connect/#/devf581dcced">here</a>.</li><li>The preview should be 15–30 seconds long.</li><li>The maximum file size is 500MB.</li><li>Upload 1–3 previews for each supported localization.</li><li>Don’t rely on specific seasons or events, keep the video general.</li><li>Use a disclaimer at the end of a preview if your app requires you to log in or subscribe, or if you demonstrate features that are only available on an in-app purchase basis;</li><li>Avoid adult themes, objectionable content, profanity, and violence, so that your previews comply with age restrictions — aged 4 and older;</li><li>Never demonstrate protected content without licensing rights.</li><li><strong>Official App Preview Specifications: </strong>To know about Video Specifications, App Preview Resolutions, and App Preview Requirements, visit <a href="https://help.apple.com/app-store-connect/#/dev4e413fcb8">here</a>.</li></ul><h3><strong>5. Screenshots</strong></h3><p>Use images captured from your app’s UI to visually communicate your app’s user experience. You can feature up to 10 screenshots on your App Store and Mac App Store product pages.</p><p><strong>Apple requires teams to provide screenshots for</strong></p><h4><strong>iPhone:</strong></h4><blockquote>6.5-inch screens (iPhone 14–13 Pro Max, 12 Pro Max, 11 Pro Max, 11, XS Max, and XR)</blockquote><blockquote>5.5-inch screens (iPhone 8 Plus, 7 Plus, and 6s Plus). The images you provide will scale down for smaller device sizes.</blockquote><h4><strong>iPads</strong>:</h4><blockquote>upload 12.9-inch iPad Pro (2nd generation).</blockquote><p>For screenshot specifications,<a href="https://help.apple.com/app-store-connect/#/devd274dd925"> see App Store Connect Help.</a></p><h3>6. Description</h3><p>Provide an engaging description that highlights the features and functionality of your app. The ideal description is a concise, informative paragraph followed by a short list of main features. Let potential users know what makes your app unique and why they’ll love it. Communicate in the tone of your brand, and use terminology your target audience will appreciate and understand. The first sentence of your description is the most important — this is what users can read without having to tap to read more. Every word counts, so focus on your app’s unique features.</p><p><strong>Take into account the following Apple’s recommendations regarding the product page description:</strong></p><ul><li>Keep it concise, informative, and easy to understand.</li><li>Stick to the tone of your brand.</li><li>Avoid specific terms, keep it simple.</li><li>Avoid keyword stuffing, otherwise, your app won’t pass the review.</li><li>Don’t mention prices: pricing is already disclosed on your product page and may also differ across the supported localizations.</li><li>Let users know about your awards if any, but better do it at the end of the description.</li></ul><h3><strong>7. Promotional Text</strong></h3><p>Your app’s promotional text appears at the top of the description and is up to 170 characters long. You can update the promotional text at any time without having to submit a new version of your app. Consider using this to share the latest news about your app, such as limited-time sales or upcoming features.</p><h3><strong>8. Keywords</strong></h3><p>Keywords help determine where your app displays in search results, so choose them carefully to ensure your app is easily discoverable.</p><p>Popular, functional terms, such as “jobs” or “social”, may drive a lot of traffic, but are highly competitive in the rankings. Less common terms drive lower traffic but are less competitive.</p><p>Keywords are limited to<strong> </strong>100 characters<strong> </strong>in total, with terms separated by commas and no spaces. (Note that you can use spaces to separate words within keyword phrases. For example Property, House, Real Estate.)</p><p><strong>Maximize the number of words that fit in this character limit by avoiding the following:</strong></p><ul><li>Plurals of words that you’ve already included in the singular form</li><li>Names of categories or the word “app”</li><li>Duplicate words</li><li>Special characters — such as # or @ — unless they’re part of your brand identity. Special characters don’t carry extra weight when users search for your app.</li></ul><p><strong>Improper use of keywords is a common reason for App Store rejections. Do not use the following in your keywords:</strong></p><ul><li>Unauthorized use of trademarked terms, celebrity names, and other protected words and phrases</li><li>Terms that are not relevant to the app</li><li>Competing app names</li><li>Irrelevant, inappropriate, offensive, or objectionable terms</li><li>In addition, keep in mind that promotional text doesn’t affect your app’s search ranking so it should not be used to display keywords.</li></ul><h3><strong>9. In-App Purchases </strong>(Optional)</h3><p>Users can view and start an in-app purchase from your product page. In-app purchases and subscriptions are shown in two separate sections on your product page, and you can showcase up to 20 total items across both of these sections. You can even choose the order in which to list them to help drive awareness for specific content.</p><p>Each item has its own display name, promotional image, and description. In-app purchase names are limited to <strong>30 characters</strong> and descriptions are limited to <strong>45 characters</strong>, so be descriptive, accurate, and concise when highlighting their benefits.</p><p>For details, see <a href="https://developer.apple.com/app-store/promoting-in-app-purchases/">Promoting Your In-App Purchases.</a></p><h3>10. What’s New (Not for the first release)</h3><p>When you update your app, you can use What’s New to communicate changes to users. This text appears on your product page and on the Updates tab.</p><h3>11. Ratings and reviews</h3><p>Ratings and reviews influence how your app ranks in search and can encourage users to engage with your app from search results, so focus on providing a great app experience that motivates users to leave positive reviews.</p><p>Individual ratings inform your app’s summary rating, which is displayed on your product page and in search results. This summary rating is specific to each territory on the App Store.</p><h3>12. Categories</h3><p>Categories on the App Store help users discover new apps to meet their needs. You can assign a primary and a secondary category to your app.</p><p>The primary category is particularly important for discoverability, as it helps users find your app when browsing or filtering search results, and it determines in which tab your app appears on the App Store.</p><p><strong>You’ll need to choose primary and secondary categories for your app. Your selections will come from the following options:</strong></p><blockquote>Books, Business, Developer Tools, Education, Entertainment, Finance, Food &amp; Drink, Games, Graphics &amp; Design, Health &amp; Fitness, Kids, Lifestyle, Magazines &amp; Newspapers, Medical, Music, Navigation, News, Photo &amp; Video, Productivity, Reference, Shopping, Social Networking, Sports, Stickers, Travel, Utilities, and Weather.</blockquote><p><strong>Note: If your app is specifically for kids ages 11 and under, select the “Made for Kids” checkbox to indicate a particular categorical case.</strong></p><p>For details, see <a href="https://developer.apple.com/app-store/categories/">Choosing a Category</a>.</p><h3>13. Localization (Optional)</h3><p>If your app is available in multiple languages, make sure to localize your app description, keywords, app previews, and screenshots, for each of the markets in which you offer your app.</p><p>You can also translate your app’s name and tailor your keywords to reflect the values of each market so your app might better resonate with the local audience.</p><p>For details, see <a href="https://help.apple.com/app-store-connect/#/deve6f78a8e2">Localize App Store information.</a></p><h3>14. Support URL</h3><p>Provide a support URL link to the page on your website where users can find customer help and resources for your app.</p><h3>15. Marketing URL</h3><p>Submit a marketing URL link to a page on your website where users can find product information about your app.</p><h3>16. App Privacy policy URL</h3><p>Submit a privacy URL that links to your privacy policy. A privacy policy is required for all apps</p><h3>17. App Review Information</h3><p>Provide contact information including</p><blockquote><em>name,</em></blockquote><blockquote><em>phone number</em></blockquote><blockquote><em>email address</em></blockquote><p>of the person, Apple can reach if they have questions during the review process.</p><p>Notes (optional): Additional information about your app that can help during the review process. Include information that may be needed to test your app, such as app-specific settings.</p><h3><strong>18. Authentication Details </strong>(Dev team will do)</h3><p>Create authentication details (typically a username and password) for the reviewer if login is required for your app. If your app uses something other than a username and password, provide these details in the App Review notes. If an Apple team member can’t sign in, then your review will stop until the issue is resolved.</p><p>Note: Be sure that you can authenticate these credentials in your production environment before submitting a new build for review.</p><h3><strong>19. Attachment </strong>(Optional)</h3><p>You can attach specific app documentation, demo videos, and other items to help prevent delays during the app review process. Make sure you use files with the following extensions: .pdf, .doc, .docx, .rtf, .pages, .xls, .xlsx, .numbers, .zip, .rar, .plist, .crash, .jpg, .png, .mp4, or .avi. We recommend you keep your video to 2 minutes or less.</p><h3><strong>20. Other Params</strong></h3><p><strong>Content Rights</strong></p><p>Apple requires applicants to demonstrate their legal right to leverage third-party commercial content (such as art and music). Therefore, teams should be prepared to provide this documentation even though the App Store listing does not include it.</p><p><strong>Primary Language</strong></p><p>Your product’s primary language is used as the default for App Store metadata when you don’t provide localized information.</p><p><strong>Age Rating</strong></p><p>The age rating is the minimum age for which your app is deemed appropriate. You won’t provide an age rating directly. Instead, you’ll answer a series of questions about topics that are not suitable for all ages, such as violence and profanity. Apple will then assign an appropriate age rating based on your responses.</p><p><strong>License Agreement</strong></p><p>You may provide your own license agreement or adopt Apple’s policy by default.</p><p><strong>Pricing &amp; Availability</strong></p><p>Your pricing and availability selections are part of your App Store properties. You can establish tiered pricing (e.g., free, $0.99, $1.99, etc.) and determine which countries should make your app available. When you set pricing, you also specify the effective date for your pricing to change.</p><h3>Conclusion</h3><p>Wow great 🎉 , Hope this blog is helpful to know the detailed view on Appstore listing guidelines. I’m passionate about helping fellow developers and entrepreneurs succeed and I can’t wait to share my knowledge with you all.</p><blockquote>This article helped you? Long press on the 👏 button as long as you can.</blockquote><blockquote>I got something wrong? Mention it in the comments. I would love to improve.</blockquote><blockquote>I am NavinKumar, Lead Application developer @IBM. You can find me on <a href="https://www.linkedin.com/in/navin-kumar/">Linkedin</a> or stalk me on <a href="https://github.com/navinkumar0118">GitHub</a> or Follow me on <a href="https://medium.com/@navinkumar0118">Medium</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7ac1ff75aa9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Countdown Timer works in Background]]></title>
            <link>https://navinkumar0118.medium.com/flutter-countdown-timer-works-in-background-f87488b0ba4c?source=rss-baa46aff279------2</link>
            <guid isPermaLink="false">https://medium.com/p/f87488b0ba4c</guid>
            <category><![CDATA[timer]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[countdown]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Navin Kumar]]></dc:creator>
            <pubDate>Thu, 17 Aug 2023 08:15:31 GMT</pubDate>
            <atom:updated>2023-08-22T15:27:04.733Z</atom:updated>
            <content:encoded><![CDATA[<p>Timer which works on both foreground and background using the simplest approach without any plugins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bDJdbKHvBbxLP4ss_SAQ1A.png" /></figure><h3>Intro</h3><p>In this blog, we will see how to run a countdown timer that works both foreground and background threads without any plugin in <a href="https://github.com/navinkumar0118/NavTimer">NavTimer</a> flutter project.</p><h3>Why this blog</h3><p>As a native developer, I thought it was easy to implement a background countdown timer in Flutter for both platforms.</p><p>But here comes the problem,</p><blockquote><strong>ISSUES</strong></blockquote><ul><li>The default flutter <strong>Timer</strong> class will work only in the foreground, not the background. when the app goes to the background on ios then the timer state will be stopped automatically.</li><li>This will give improper timer values when the app goes to the background.</li><li>To overcome this, we can use <strong>Isolates</strong>, again it will not work on background in some cases.</li><li>To run the timer on the background we need to use <strong>plugins</strong> based on background thread operations. <em>(work manager, flutter background service, background fetch) etc.</em></li><li>But these plugins will not comply with both Android and ios platforms.</li><li>So again we need to do some workarounds on both <strong>native side classes</strong>.</li></ul><blockquote>To show a timer countdown in a flutter, why do we need to take too much-complicated kinds of stuffs?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*b33fYl4F_CFcF9rtNdnMVw.gif" /></figure><ul><li>That&#39;s why this blog comes, here I will show the <strong>simplest approach using the Timer class</strong> which resolves the aforementioned issues on both platforms.</li></ul><h3>Solution</h3><ul><li><em>Using Timer class for counting each second, when the app goes to background (“on pause”) Then we will mark this time as the </em><strong><em>last reference point</em></strong><em>. and the timer will be stopped.</em></li><li><em>When the app comes to the foreground (“on resume”), the </em><strong><em>current time</em></strong><em> will be compared with the last reference time.</em></li><li><em>Then the difference between two-time points will be calculated and shown in the UI layer. Then the timer will be started with the latest end time.</em></li></ul><p>Sounds good! right...</p><h4>I have found many posts and solutions on this approach, but no one solution has not worked perfectly. Where some cases have been missed or not handled properly.</h4><p>ok Let&#39;s dive,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*CZ0QLSoTQOnTqBtXMNjV4A.gif" /></figure><h3>TimerDifferenceHandler Class</h3><p>This class will handle the time difference between the current time and the ending time when the app comes from the background.</p><pre>class TimerDifferenceHandler {<br>  static late DateTime endingTime;<br><br>  static final TimerDifferenceHandler _instance = TimerDifferenceHandler();<br><br>  static TimerDifferenceHandler get instance =&gt; _instance;<br><br>  int get remainingSeconds {<br>    final DateTime dateTimeNow = DateTime.now();<br>    Duration remainingTime = endingTime.difference(dateTimeNow);<br>    // Return in seconds<br>    LoggerUtil.getInstance.print(<br>        &quot;TimerDifferenceHandler  -remaining second = ${remainingTime.inSeconds}&quot;);<br>    return remainingTime.inSeconds;<br>  }<br><br>  void setEndingTime(int durationToEnd) {<br>    final DateTime dateTimeNow = DateTime.now();<br>    // Ending time is the current time plus the remaining duration.<br>    endingTime = dateTimeNow.add(<br>      Duration(<br>        seconds: durationToEnd,<br>      ),<br>    );<br>    LoggerUtil.getInstance.print(&quot;TimerDifferenceHandler  -setEndingTime = ${endingTime.toLocal().toString()}&quot;);<br>  }<br>}</pre><ul><li>on timer starts, we need to set the end time value on TimerDifferenceHandler, so that the end time will be marked.</li><li>once the app goes to the background(on resume), that time will be set as the ending time on TimerDifferenceHandler.</li><li>So when the app comes to the foreground (on resume), then that time (<strong>current time</strong>) will be calculated as the difference with the last <strong>ending time.</strong></li><li>This difference time (secs) will be handled on <strong>remainingSeconds.</strong></li></ul><h3>CountDownTimer Class</h3><p>This will be the base helper class that handles all timer operations.</p><pre>class CountdownTimer {<br>  int _countdownSeconds;<br>  late Timer _timer;<br>  final Function(int)? _onTick;<br>  final Function()? _onFinished;<br>  final timerHandler = TimerDifferenceHandler.instance;<br>  bool onPausedCalled = false;<br><br>  CountdownTimer({<br>    required int seconds,<br>    Function(int)? onTick,<br>    Function()? onFinished,<br>  })  : _countdownSeconds = seconds,<br>        _onTick = onTick,<br>        _onFinished = onFinished;<br><br>  //this will start the timer<br>  void start() {<br>    _timer = Timer.periodic(const Duration(seconds: 1), (timer) {<br>      _countdownSeconds--;<br>      if (_onTick != null) {<br>        _onTick!(_countdownSeconds);<br>      }<br><br>      if (_countdownSeconds &lt;= 0) {<br>        stop();<br>        if (_onFinished != null) {<br>          _onFinished!();<br>        }<br>      }<br>    });<br>  }<br><br><br>  //on pause current remaining time will be marked as end time in timerHandler class<br>  void pause(int endTime) {<br>    onPausedCalled = true;<br>    stop();<br>    timerHandler.setEndingTime(endTime); //setting end time<br>  }<br><br>  //on resume, the diff between current time and marked end time will be get from timerHandler class<br>  void resume() {<br>    if(!onPausedCalled){<br>      //if on pause not called, instead resumed will called directly.. so no need to do any operations<br>      return;<br>    }<br>    if (timerHandler.remainingSeconds &gt; 0) {<br>      _countdownSeconds = timerHandler.remainingSeconds;<br>      start();<br>    } else {<br>      stop();<br>      _onTick!(_countdownSeconds); //callback<br>    }<br>    onPausedCalled = false;<br>  }<br><br>  void stop() {<br>    _timer.cancel();<br>    _countdownSeconds = 0;<br>  }<br>}</pre><h4><strong>start()</strong></h4><ul><li>This will start the timer countdown on decrementing the value _countdownSeconds<strong>.</strong></li><li><strong>_countdownSeconds </strong>will be the timer end limit.</li></ul><h4>pause()</h4><ul><li>when the app goes to the background, onPause will be called from ui layer.</li><li>At this time, It will set the ending time for the <strong>TimerHandler</strong> class and the timer will be stopped.</li></ul><pre>//on pause current remaining time will be marked as end time in timerHandler class<br>  void pause(int endTime) {<br>    onPausedCalled = true;<br>    stop();<br>    timerHandler.setEndingTime(endTime); //setting end time<br>  }</pre><ul><li>This will mark the last timer&#39;s remaining seconds while going background.</li></ul><h4>resume()</h4><ul><li>on resuming (app coming into the foreground) after some time, then the current time will be compared with the last ending time on <strong>TimerHandler</strong> class.</li><li>This difference time (seconds) will be again set to start() function as <strong>endtime</strong> in <strong>CountDownTimer</strong> class.</li></ul><pre>_countdownSeconds = timerHandler.remainingSeconds;</pre><ul><li>Whenever the app goes to the background and foregrounds routinely, then the timer endpoint is set and the time difference is calculated on the current time.</li><li>So the timer will run seamlessly on both threads without any issues.</li></ul><h4>stop()</h4><ul><li>once the timer is completed, then stop() will be triggered. This function will stop the timer process.</li></ul><pre>void stop() {<br>    _timer.cancel();<br>    _countdownSeconds = 0;<br>  }</pre><h4>onPausecalled boolean</h4><ul><li>In ios, onresume can be called without onpause being called, so in this case, the timer will start multiple times and give wrong timer values.</li><li>So This boolean is handled to check if the app goes to the background without calling the <strong>pause()</strong> function. (This will happen on an ios device).</li><li>So only if <strong>pause()</strong> is called, then only the <strong>resume()</strong> function will handle timer diff operations. else returned.</li></ul><pre>void resume() {<br>    if(!onPausedCalled){<br>      //if on pause not called, instead resumed will called directly.. so no need to do any operations<br>      return;<br>    }<br>    if (timerHandler.remainingSeconds &gt; 0) {<br>      _countdownSeconds = timerHandler.remainingSeconds;<br>      start();<br>    } else {<br>      stop();<br>      _onTick!(_countdownSeconds); //callback<br>    }<br>    onPausedCalled = false;<br>  }</pre><h3><strong>UI Layer</strong></h3><ul><li><strong>calling timer functionality on ui layer.</strong></li></ul><pre> int countdownSeconds = 180; //total timer limit in seconds<br> late CountdownTimer countdownTimer; <br> bool isTimerRunning = false;<br><br>void initTimerOperation() <br>{<br><br>//timer callbacks<br>countdownTimer = CountdownTimer(<br>  seconds: countdownSeconds,<br>  onTick: (seconds) {<br>    isTimerRunning = true;<br>    countdownSeconds = seconds; //this will return the timer values <br>  },<br>  onFinished: () {<br>    isTimerRunning = false;<br>    countdownTimer.stop();<br>    // Handle countdown finished<br>  },<br>);<br><br>//native app life cycle <br>SystemChannels.lifecycle.setMessageHandler((msg) {<br><br>// On AppLifecycleState: paused<br>  if (msg == AppLifecycleState.paused.toString()) {<br>    if (isTimerRunning) {<br>      countdownTimer.pause(countdownSeconds); //setting end time on pause<br>    }<br>  }<br><br><br>// On AppLifecycleState: resumed<br>  if (msg == AppLifecycleState.resumed.toString()) {<br>    if (isTimerRunning) {<br>      countdownTimer.resume();<br>    }<br>  }<br>  return Future(() =&gt; null);<br>});<br><br><br>//starting timer<br>isTimerRunning = true;<br>countdownTimer?.start();<br><br>}</pre><h3>Conclusion</h3><p>Wow great 🎉, Hope this blog is helpful to implement flutter timer functionality in an efficient manner.</p><p><strong>Check out the full project: </strong><a href="https://github.com/navinkumar0118/NavTimer"><strong><em>NavTimer</em></strong></a></p><blockquote>This article helped you? Long press on the 👏 button as long as you can.</blockquote><blockquote>I got something wrong? Mention it in the comments. I would love to improve.</blockquote><blockquote>I am NavinKumar, Lead Application developer @IBM. You can find me on <a href="https://www.linkedin.com/in/navin-kumar/">Linkedin</a> or stalk me on <a href="https://github.com/navinkumar0118">GitHub</a> or Follow me on <a href="https://medium.com/@navinkumar0118">Medium</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f87488b0ba4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advance Architecture for Android Project]]></title>
            <link>https://navinkumar0118.medium.com/advance-architecture-for-android-project-ecdab8eb2b2b?source=rss-baa46aff279------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecdab8eb2b2b</guid>
            <category><![CDATA[android-project-structure]]></category>
            <category><![CDATA[android-architecture]]></category>
            <category><![CDATA[android-components]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack]]></category>
            <dc:creator><![CDATA[Navin Kumar]]></dc:creator>
            <pubDate>Wed, 29 Jun 2022 12:30:05 GMT</pubDate>
            <atom:updated>2022-07-04T16:50:25.887Z</atom:updated>
            <content:encoded><![CDATA[<p>Best way to create advanced android projects using the latest android architecture and components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9m66fs3a9f1mSQcPNn1asw.png" /></figure><h3><strong>Intro</strong></h3><p>In this blog, we will discuss a simple app (<a href="https://github.com/navinkumar0118/NavArch"><strong>NavArch</strong></a>) using advanced android architecture. <a href="https://github.com/navinkumar0118/NavArch"><strong>NavArch</strong></a><strong> </strong>will show a list of pokemon names. Before diving into deep, I hope you are already familiar with these topics: Retrofit, Dependy injection (Hilt), Jetpack components, MVVM.</p><p>In this app, we have used android&#39;s latest architectural components like Jetpack Navigation, ViewModel, Databinding, Live data, Hilt, and Single activity structure.</p><h3><strong>Architecture</strong></h3><p>We have used<a href="https://developer.android.com/topic/architecture"> Google’s recommended app architecture</a>, where each application should have at least two layers:</p><ol><li>UI Layer (Presentation Layer)</li><li>Data Layer (Repository Layer)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*RtRuduWFnwq5V1cV367Qzw.png" /></figure><p><a href="https://github.com/navinkumar0118/NavArch"><strong>NavArch</strong></a><strong> </strong>consists of only two layers <strong>UI layer</strong> and the <strong>Data layer</strong>. we are not focusing on the Domain layer. let’s dive deep.</p><h4>UI Layer</h4><p>The UI layer is the presentation layer that takes care of displaying data on the screen and handling UI elements and State. (Views, Texts, Buttons, Adapters, etc.)</p><p>Also, all the UI logic and validation will be handled in this layer. This operation can be shared between the Activity/Fragment and ViewModel.</p><p>This layer is made up of two things:</p><ul><li><strong>UI Elements (Activity / Fragments / Data Binding)</strong>: will perform UI operations, displaying content, validation, and getting input from the user.</li><li><strong>UI State Holder (Viewmodel)</strong>: This will hold the UI state, handle UI logic, and holds all the data objects.</li></ul><h4>Data Layer</h4><p>The Data layer is responsible for handling all the business logic. This layer is made up of two things:</p><ul><li><strong>Repositories: </strong>This class is responsible for handling business logic, exposing data, fetching data from multiple data sources, and processing.</li><li><strong>Data Sources: </strong>Data source class is responsible for fetching data from multiple sources like API Service and Local DB.</li><li>eg: Fetching data from Retrofit call or Room DB.</li></ul><p><strong>Activity</strong>/<strong>Fragment</strong> will only communicate with ViewModel, ViewModel will get the processed data from the Repository class.</p><p><strong>Repository</strong> will fetch data from multiple data source classes, then validate the data and return it to ViewModel.</p><p><strong>Datasource</strong> class will get the data from the source and send it back to the Repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*u47p_HJoIeN8xRbSjcP0RA.png" /></figure><p>Hope you are clear with these Architecture Layers, OK let&#39;s discuss this approach in our <a href="https://github.com/navinkumar0118/NavArch"><strong>NavArch</strong></a> app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*BLQj0F6eXygGcE9Zy0IB_Q.gif" /></figure><h3>Project (<a href="https://github.com/navinkumar0118/NavArch">NavArch</a>)</h3><ul><li>“NavArch” app will contain a simple list(<strong>Pokemon</strong>) of data to understand the Advance architecture design.</li><li>In this app, we have used free <a href="https://pokeapi.co/"><strong>Pokeapi</strong></a><strong> </strong>to get the pokemon list data.</li><li>Ok, let&#39;s see it in detail.</li></ul><h4><strong>project packages</strong></h4><ul><li>NavArch will contain the following package structure. (you can also create an <strong>individual module</strong> for each layer)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*iD9HObl5ajRIckVrvHfM4Q.png" /><figcaption>project structure</figcaption></figure><h4>1) UI</h4><ul><li>UI package will be responsible for handling the UI layer operations. All the Activities, Fragments, ViewModels, UI classes, and Adapter classes will be placed inside this package.</li><li>Every UI flow will be added to this package.</li><li>eg: <strong>launcher, home, view.</strong></li></ul><h4><strong>2) Data</strong></h4><ul><li>This package holds API service, Repository, Model, and DB classes.</li></ul><blockquote><strong>api</strong></blockquote><ul><li>The<strong> </strong>API package will handle the API service logic and operations. It will have API request/response classes, Retrofit API service, and BaseRemoteDataSource class.</li><li><strong>ApiService - </strong>Interface class to handle HTTP calls and responses.</li><li><strong>BaseRemoteDataSource - </strong>This class will load the response from API and convert it into a Result Object. (all the responses will be encapsulated as a <strong>Result</strong> object).</li></ul><blockquote><strong>model</strong></blockquote><ul><li>This package holds all the model (POJO) classes of the project.</li><li>eg: <strong>Pokemon</strong></li></ul><blockquote><strong>repository</strong></blockquote><ul><li>Every business logic and operation have been handled inside this package. This package holds all the repository classes for each flow.</li><li>eg: <strong>LoginRepository</strong></li></ul><h4><strong>3) DI</strong></h4><ul><li>This package holds the dependency injection(Hilt) base module classes.</li><li>eg:<strong> NetworkModule - </strong>This DI class will provide a Retrofit API instance.</li></ul><h4><strong>4) Common</strong></h4><ul><li>This package holds common classes like Constants, Utils, Helper, and Receivers.</li></ul><h4><strong>5) Base</strong></h4><ul><li>This package has base classes like BaseActivity, BaseFragments, BaseSharePref, and MainApplication(Hilt).</li></ul><p>Hope you are clear with these packages and their scope.</p><p>After creating all the packages and classes, your project structure should be like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*RmpebMM1f9dELBpJjmZrjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*NPT4Zb-Z5cjVa7rzeyb-1g.png" /></figure><h3>Project Repo</h3><blockquote><a href="https://github.com/navinkumar0118/NavArch"><strong>NavArch</strong></a><strong> </strong>implements an Advance android architecture and contains a Launcher page and Home page. Pokemon data is fetched from API and updated on recycler view in HomePage.</blockquote><p>Please find the project <a href="https://github.com/navinkumar0118/NavArch"><strong>Github</strong> repo</a> here, hope you can get a detailed view of discussed topics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nis8LJNMHYibIXPUlR6lgQ.png" /></figure><h3>Wrapping Up</h3><p>Wow great 🎉, In this blog, we have learned about how to create an android app using Advance Architecture and components. Hope this blog is helpful.</p><blockquote>This article helped you? Long press on the 👏 button as long as you can.</blockquote><blockquote>I got something wrong? Mention it in the comments. I would love to improve.</blockquote><blockquote>I am NavinKumar, Android and Flutter developer. You can find me on <a href="https://www.linkedin.com/in/navin-kumar/">Linkedin</a> or stalk me on <a href="https://github.com/navinkumar0118">GitHub</a> or Follow me on <a href="https://medium.com/@navinkumar0118">Medium</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecdab8eb2b2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Show Unity View inside Native Android App]]></title>
            <link>https://navinkumar0118.medium.com/show-unity-view-inside-native-android-app-8035b9b6895a?source=rss-baa46aff279------2</link>
            <guid isPermaLink="false">https://medium.com/p/8035b9b6895a</guid>
            <category><![CDATA[unity-as-library]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity-library]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-unity]]></category>
            <dc:creator><![CDATA[Navin Kumar]]></dc:creator>
            <pubDate>Wed, 31 Mar 2021 13:52:11 GMT</pubDate>
            <atom:updated>2021-04-01T08:53:11.879Z</atom:updated>
            <content:encoded><![CDATA[<p>Integrating Unity as a library inside native Android application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oRbI2VR9DfCsKX913p8XHw.png" /></figure><h3><strong>Intro</strong></h3><p>In this blog we will integrate Unity project as an library inside native android project. Lets dive deep into it.</p><p>To implement Unity features inside native apps we need to change Unity Project as a library, and then integrate inside our native application.</p><p>From <strong>version 2019.3.a2</strong> Unity introduced a new feature <strong>Unity as a library</strong> in native apps both <strong>Android</strong> and <strong>Ios</strong>.</p><h3>Export Unity Project as an Library (Android)</h3><p>Hope you already have an unity project, then follow the below steps.</p><ul><li>Goto Build settings in Unity Editor,<strong> Switch Platform to Android.</strong></li><li>Just check the option “<strong>Export Project</strong>”.</li><li>Then click <strong>Export.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*NC8HFwTamgtf0rLAjtbSwA.png" /></figure><p><em>note: Dont change Scripting Background to</em><strong><em> IL2CPP </em></strong><em>and Target architectures </em><strong><em>ARM64</em></strong><em>. only check the option “Export project”</em></p><ul><li>Now Unity project has exported successfully in desired path.</li><li>Previously, the exported Unity project will have only one gradle module and one manifest file.</li><li>But now the Structure has been changed to <strong>two</strong> <strong>gradle</strong> <strong>modules</strong>.</li></ul><h4><strong>1. launcher</strong></h4><h4><strong>2.unityLibrary</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*DsUAQpmi8HR6EvHd3h4pRw.png" /></figure><ul><li>Both <strong>launcher</strong> and <strong>unityLibrary</strong> module will have its own build.gradle and manifest files.</li><li><strong>unityLibrary -</strong> module will have Unity runtime and project data, it can be easily integrated into any other gradle project. It will help to integrate Unity inside our native android project.</li><li><strong>launcher -</strong> module will have all icons and the application name.</li><li>But we want use only <strong>unityLibrary </strong>module as an library inside our native android project.</li></ul><h3>Add Unity Library Module inside Native Android Project</h3><p>Now we are going to add <strong>unityLibrary</strong> module inside our native project, follow the below steps.</p><ul><li>Open new/existing native android project in Android studio.</li></ul><ol><li>In Android studio Goto <strong>settings.gradle </strong>file, add the folowing code;</li></ol><pre>include &#39;:unityLibrary&#39;<br>project(&#39;:unityLibrary&#39;).projectDir = new File(&#39;/Users/admin/Documents/UnityProject/unityLibrary&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3LN06diuZQnf-4fWD_Jnfg.png" /></figure><ul><li>Now copy the <strong>unityLibrary </strong>folder path, which we exported from Unity and replace it inside <strong>File(‘&lt;<em>unityLibrary path&gt;’</em>)</strong></li></ul><p>2. Now Open <strong>build.gradle(Module:app)</strong></p><ul><li>Add the following line inside <strong>dependencies{ }</strong></li></ul><pre>dependencies {<br>.....<br>.....<br> implementation project(&#39;:unityLibrary&#39;)<br> implementation fileTree(dir: project(&#39;:unityLibrary&#39;).getProjectDir().toString() + (&#39;\\libs&#39;), include: [&#39;*.jar&#39;])<br><strong>}</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vY_o9Fg5UXvQA-9vXAgrRQ.png" /></figure><ul><li>Add the following line inside <strong>defaultConfig{ }</strong></li></ul><pre>defaultConfig <strong>{<br> .....<br> .....</strong></pre><pre> ndk<strong>{<br>        </strong>abiFilters &#39;armeabi-v7a&#39;,&#39;x86&#39;<br>    <strong>}<br>}</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ptsz7y3yNDDB-nBCfpznAw.png" /></figure><p>3. Now Open <strong>build.gradle(Project: NativeAndroid)</strong></p><ul><li>Add the following inside <strong>allprojects</strong> -&gt; <strong>repositories</strong></li></ul><pre>allprojects <strong>{<br>    </strong>repositories {<strong><br></strong><br>        flatDir <strong>{<br>            </strong>dirs &quot;$<strong>{</strong>project(&#39;:unityLibrary&#39;).projectDir<strong>}</strong>/libs&quot;<br>        <strong>}<br>    }<br>}</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*THa-TNP0N6mILpBy_9fMVg.png" /></figure><p>4. Click <strong>Sync Now, </strong>now gradle files has been synced.</p><p><strong>note: If below error occurs,</strong></p><blockquote>Error:<em> Could not get unknown property ‘unityStreamingAssets’ for object of type com.android.build.gradle.internal.dsl.AaptOptions.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*K0VCaRRvzd_a5g0wE0hPDw.gif" /></figure><blockquote>Add this line inside <strong>gradle.properties</strong></blockquote><pre>unityStreamingAssets=.unity3d, google-services-desktop.json, google-services.json, GoogleService-Info.plist</pre><p>Then try again to sync gradle.</p><p>Now <strong>unityLibrary</strong> has been successfully added inside your android project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*D9GAEBg17gNB-9VW9ke_DQ.png" /></figure><h3>Show Unity View inside Android Activity</h3><p>Now unityLibary is added, we can access all the unity files inside our android project. To show unity view inside android activity follow below steps accordingly.</p><ol><li>Create Two Activities <strong>MainActivity</strong> and <strong>UnityActivity</strong></li><li>Create a Button in MainActivity on clicking this button navigate to <strong>UnityActivity</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*crAJEr7uE8bh3TeOEFiOhg.png" /></figure><p>3. In <strong>UnityActivity </strong>inside oncreate() method, add below code to open <strong>UnityPlayerActivity </strong>(which shows unity screen).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*0w8hSv_lRuNG4STyRtLdVg.png" /></figure><ul><li>When<strong> UnityPlayerActivty </strong>is called it launches unityPlayer, where unity screen will be shown inside android activity..</li></ul><blockquote><strong>important note:</strong> Dont forgot to add this line inside <strong>strings.xml </strong>folder in app folder</blockquote><pre>&lt;string name=&quot;game_view_content_description&quot;&gt;Game View&lt;/string&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*FvCihnmYPKy_tMlhNT4WeQ.png" /></figure><p>3. Now run the app in your Device, <strong>Unity</strong> <strong>view</strong> will be loaded inside your <strong>UnityActivity</strong> successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*HmDtzf-JkZEwQq2zx3K8zw.gif" /></figure><h3>Wrapping Up</h3><p>Wow great 🎉, In this blog we have learned about how to implement unity feature inside native android application and also handled possible issues.Hope this blog is helpful.</p><blockquote>This article helped you? Long press on the 👏 button as long as you can.</blockquote><blockquote>I got something wrong? Mention it in the comments. I would love to improve.</blockquote><blockquote>I am NavinKumar, Android and Flutter developer. You can find me on <a href="https://www.linkedin.com/in/navin-kumar/">Linkedin</a> or stalk me on <a href="https://github.com/navinkumar0118">GitHub</a> or Follow me on <a href="https://medium.com/@navinkumar0118">Medium</a> and Insta</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8035b9b6895a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Power Of Your Subconscious Mind Summary]]></title>
            <link>https://navinkumar0118.medium.com/the-power-of-your-subconscious-mind-summary-ebf7eafc8926?source=rss-baa46aff279------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebf7eafc8926</guid>
            <category><![CDATA[joshep-murphy]]></category>
            <category><![CDATA[power-of-subconsious-mind]]></category>
            <category><![CDATA[power-of-mind]]></category>
            <category><![CDATA[the-power-of-thought]]></category>
            <category><![CDATA[subconscious-mind]]></category>
            <dc:creator><![CDATA[Navin Kumar]]></dc:creator>
            <pubDate>Fri, 27 Mar 2020 20:03:43 GMT</pubDate>
            <atom:updated>2020-05-30T08:19:09.139Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*Jdu8Hg4-tHlyFCPIoR6BZw.png" /></figure><p><a href="https://amzn.to/2TPrfjp">https://amzn.to/2TPrfjp</a></p><h3>About Book:</h3><p><a href="https://amzn.to/2UzZ6MQ">The power of subconscious </a>mind book is written by <strong>Dr. Joseph Murphy </strong>in the year 1963.</p><p>By its name, this book explains about working power of our subconscious mind and reveals how to use your subconscious mind to change your life, to achieve your goals, to be successful, to be rich, to get results you want, to solve your problems, to live a healthy life, get healed from sickness<strong>.</strong></p><p><strong>Whatever you want in your life, you can get it by using your subconscious mind power.</strong></p><p>Now you are wondering what is subconscious mind and how to use it????</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*6GL2XZtpHgLeZhDA4c6Dvg.gif" /></figure><p>Before diving to it, let us know what is the conscious and subconscious mind.</p><h3>-Conscious Mind: (Objective Mind)</h3><p>Your conscious mind is the <strong>reasoning mind</strong>. you make all your decisions by using your conscious mind. Like choosing your life partner, planning, making decisions.</p><h3>-Subconscious Mind: (Subjective mind)</h3><p>Your Subconscious mind works without the help of conscious. It is independent of the conscious mind. As your heart is kept functioning automatically, your digestive functions, blood circulation, breathing are carried by the subconscious mind without the help of your conscious mind.</p><p>Now you are clear about conscious and subconscious minds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*GWJaoKa-iSQ6zAxEeg-WGg.gif" /></figure><ul><li><strong>Your Subconscious mind accepts what is impressed upon it or what you consciously believe.</strong></li><li><strong>it does not argue with you controversially as your conscious mind does, it accepts any kind of thoughts and reacts on it.</strong></li><li><strong>If you give positive thought it will respond positively, if you give negative thought it will respond negatively.</strong></li><li><strong>Your Subconscious mind simply accepts what you give as an input, it does not argue with you.</strong></li></ul><h3><strong>How Power of Subconscious mind works:</strong></h3><ul><li>The subconscious mind is the principle. It works according to the law of belief.</li><li>Everything that has happened to you, is because of thoughts impressed on your subconscious mind through belief.</li></ul><p><strong>“You are the gardener of your subconscious mind; you are planting seeds of thought in your subconscious mind every day. Your subconscious mind will give result from your thought which you have planted”</strong></p><ul><li>Whether you planted positive or negative thoughts in your subconscious mind, you will get a response based on your thought.</li><li>When the thoughts deposited in your subconscious mind, the power of subconscious mind will respond.</li><li>Whatever you have been in your life, is by your own thoughts.</li></ul><p><strong>All your experiences, actions, circumstances of your life are the reflections and reactions of your own thoughts.</strong></p><p><strong>Yes, your own thoughts are the reflection of your life. If you are poor, rich, strong, healthy, sick whatever you may be, it is by the thoughts you deposited in your subconscious mind.</strong></p><h4><strong>By changing your habitual thinking will change your life.</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*7mT4WXWksr9I5G3soYGi8g.gif" /></figure><h3><strong>How to use the Power of Subconscious mind:</strong></h3><ul><li>Let us assume you are traveling by taxi. you want to give correct directions to the driver to reach your spot. If you constantly give wrong directions, you cannot reach your spot you will fail.</li><li>Like that, you should give correct directions to your subconscious mind without any distraction, so that it will respond to you and you can achieve your desire.</li></ul><p><strong>According to your belief it is done unto you.</strong></p><p><strong>what you think you create.</strong></p><p><strong>By using your conscious mind, deposit your desire thoughts in your subconscious mind habitually, it will respond to yo</strong>u.</p><h3>Wrapping Up</h3><p>Wow great 🎉, This is the first book I read, so I decided to share a summary of this book. I hope this summary helpful, if you want to know more, there are a lot of things to know from this book. You can buy it from this link<a href="https://amzn.to/2UzZ6MQ">:https://amzn.to/2UzZ6MQ</a></p><p><a href="https://amzn.to/2TPrfjp">https://amzn.to/2TPrfjp</a></p><blockquote>This blog helped you? Long press on the 👏 button as long as you can.</blockquote><blockquote>I got something wrong? Mention it in the comments. I would love to improve.</blockquote><blockquote>I am NavinKumar, Android and Flutter developer. You can find me on <a href="https://www.linkedin.com/in/navin-kumar/">Linkedin</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebf7eafc8926" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Take a Picture using Flutter Camera]]></title>
            <link>https://navinkumar0118.medium.com/take-a-picture-using-flutter-camera-a9c11d282632?source=rss-baa46aff279------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9c11d282632</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Navin Kumar]]></dc:creator>
            <pubDate>Sat, 16 Nov 2019 13:20:28 GMT</pubDate>
            <atom:updated>2019-11-16T13:27:28.735Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ejwJzEZH2XyWs9CYQoO0ow.png" /></figure><h3><strong>Intro</strong></h3><p>Flutter mainly provides two plugins to implement camera functionality to your app,</p><ol><li><a href="https://pub.dev/packages/camera"><strong>camera</strong></a></li><li><a href="https://pub.dev/packages/image_picker"><strong>image_picker</strong></a></li></ol><p>Most of the blogs covers only about image_picker plugin, 90% percent will go with <strong>image_picker</strong> only, so i came up with <strong>camera plugin</strong>, ok first lets see the differents between them,</p><ul><li><a href="https://pub.dev/packages/camera"><strong>camera</strong></a> plugin allows you to integrate the camera feature within your app as a Widget, where you can customise the widget.</li><li><a href="https://pub.dev/packages/image_picker"><strong>image_picker</strong></a> will launch camera application to take photo and gallery application to pick image, then return taken/selected image as aFile.</li></ul><p>Hope you are clear with these plugins, Ok Lets implement camera plugin to our Flutter app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*H4SwlsvhzJ83Y8gDuxfhDg.gif" /></figure><h3>Add dependencies</h3><ul><li>Add below dependency in <strong>pubspec.yaml </strong>file, under dependencies:</li></ul><pre>dependencies:<br>  flutter:<br>   sdk: flutter<br><strong>  camera:<br>  path_provider:<br>  path:</strong></pre><h4>- iOS</h4><p>Add two rows to the ios/Runner/Info.plist:</p><pre>&lt;key&gt;NSCameraUsageDescription&lt;/key&gt;<br>&lt;string&gt;Enable myApp to access your camera to capture your photo&lt;/string&gt;<br>&lt;key&gt;NSMicrophoneUsageDescription&lt;/key&gt;<br>&lt;string&gt;Enable myApp to access mic to record your voice&lt;/string&gt;</pre><h4>- Android</h4><p>Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.</p><pre>minSdkVersion 21</pre><ul><li>Now add header file <strong>import ‘package:camera/camera.dart’;</strong></li></ul><h3>Initialize<strong> Camera</strong></h3><ul><li>first we need to initialize camera on initState(),</li></ul><pre>CameraController _controller;<br>Future&lt;void&gt; _initializeControllerFuture;</pre><pre>isCameraReady = false;<br>showCapturedPhoto = false;<br>var ImagePath;</pre><pre>@override<br>void initState() {<em><br>  </em>super.initState();<br>  _initializeCamera(); <br>  <br>}</pre><pre>Future&lt;void&gt; _initializeCamera() async {<br>  final cameras = await availableCameras();<br>  final firstCamera = cameras.first;<br>  _controller = CameraController(firstCamera,ResolutionPreset.high);<br>  _initializeControllerFuture = _controller.initialize();<br>  if (!mounted) {<br>    return;<br>  }<br>  setState(() {<br>    isCameraReady = true;<br>  });<br>}</pre><ul><li><strong>availableCameras() </strong>will return list of avalaible cameras in the device, first camera from list will be passed to cameraController.</li></ul><pre>_controller = CameraController(firstCamera,ResolutionPreset.high);</pre><ul><li><strong>cameraController</strong> controlls the camera functionality, firstCamera and ResolutionPreset as a parameter, we can set ResolutionPreset as <strong>high, medium, low, max, ultraHigh, veryHigh, values.</strong></li><li>Then Initialize the controller , which returns Future.</li></ul><pre>_initializeControllerFuture = _controller.initialize();</pre><ul><li>now set isCameraReady as true and update the state.</li></ul><h4>- Android</h4><ul><li>In Android, when app goes to background (onPause() )android core will automatically dispose the camera list, so while resuming the app, it will be freezed and cant accessible.</li><li>So that we need to initailse the camera on onResume() also</li></ul><pre>@override<br>void didChangeAppLifecycleState(AppLifecycleState state) {<br>  if (state == AppLifecycleState.resumed) {<br>    _controller != null<br>        ? _initializeControllerFuture = _controller.initialize()<br>        : null; //on pause camera is disposed, so we need to call again &quot;issue is only for android&quot;<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*64QQWh65mDB4GbNYrEhVKA.gif" /></figure><h3>Display CameraPreview</h3><ul><li>Use the CameraPreview widget from the camera package to display a preview of the camera’s feed.</li></ul><pre>final size = MediaQuery.<em>of</em>(context).size;<br>final deviceRatio = size.width / size.height</pre><pre>FutureBuilder&lt;void&gt;(<br>  future: _initializeControllerFuture,<br>  builder: (context, snapshot) {<br>    if (snapshot.connectionState == ConnectionState.done) {<br>      // If the Future is complete, display the preview.<br>      return Transform.scale(<br>          scale: _controller.value.aspectRatio / deviceRatio,<br>          child: Center(<br>            child: AspectRatio(<br>              aspectRatio: _controller.value.aspectRatio,<br>              child: CameraPreview(_controller), //cameraPreview<br>            ),<br>          ));<br>    } else {<br>      return Center(<br>          child:<br>              CircularProgressIndicator()); // Otherwise, display a loading indicator.<br>    }<br>  },<br>),</pre><ul><li>CameraPreview is wrapped with <strong>Transform</strong> widget to fit perfect to all device ratio without stretching.</li><li><strong>_initializeControllerFuture </strong>will returns on future, So FutureBuilder is used.</li><li>Then builder builds the CameraPreview Widget once future is returned, if not<strong> CircularProgressIndicator()</strong> will be shown until camera is ready.</li><li>pass _controller as parameter of <strong>CameraPreview(_controller).</strong></li></ul><h3>Take a picture with the CameraController</h3><ul><li>create a Button that takes a picture using the CameraController when a user taps on the button call <strong>onCaptureButtonPressed()</strong> method,</li></ul><pre>void onCaptureButtonPressed() async {  //on camera button press<br>  try {<br><br>    final path = join(<br>      (await getTemporaryDirectory()).path, //Temporary path<br>      &#39;$pageStatus${DateTime.now()}.png&#39;,<br>    );<br>ImagePath = path;</pre><pre>await _controller.takePicture(path); //take photo<br><br>    setState(() {<br>      showCapturedPhoto = true;<br>    });<br>  } catch (e) {<br>    print(e);<br>  }<br>}</pre><ul><li>To take a picture we should provide a <strong>path</strong> to the <strong>_controller</strong>, where the taken photo want to be stored.</li><li><strong>getTemporaryDirectory() </strong>method<strong> </strong>returns available tempory path, update this path with timeStamp and extension of the file(<strong>.png</strong> or <strong>.jpg</strong>).</li><li><strong>_controller.takePicture(path) </strong>will capture the photo and store the photo in given path.</li></ul><h3>Show the taken picture with an Image widget</h3><pre>Center(child: Image.file(File(<strong>ImagePath</strong>)));</pre><ul><li>Taken photo is displayed by Image widget.</li></ul><h3><strong>Dispose controller</strong></h3><ul><li>Finally dont forget to dispose camera <strong>_controller</strong></li></ul><pre>@override<br>void dispose() {<br>  // <em>TODO: implement dispose</em><br>  _controller?.dispose();<br>  super.dispose();<br>}</pre><h3><strong>Issues</strong></h3><h4>- Android</h4><ul><li>On Android while asking camera permission at first time, <strong>app will be crashed, </strong>this due to some technical issue on <strong>camera plugin</strong>, Dont worry i found a solution for this,if this issue occurs please follow this <a href="https://github.com/flutter/flutter/issues/19595#issuecomment-540402580">solution</a>.</li><li>You should modify some code inside flutter camera package.</li></ul><pre>..GoTo<strong><em> flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.5.5+1/android/src/main/java/io/flutter/plugins/camera/Camera.java</em></strong></pre><p><strong>Add below code on the line 424</strong></p><pre>public void startPreview() throws CameraAccessException {<br><strong>if (pictureImageReader != null) //add this line as </strong><br>createCaptureSession(CameraDevice.TEMPLATE_PREVIEW, pictureImageReader.getSurface());<br>}</pre><p><strong>solution link: </strong><a href="https://github.com/flutter/flutter/issues/19595#issuecomment-540402580">https://github.com/flutter/flutter/issues/19595#issuecomment-540402580</a></p><h3>Wrapping Up</h3><p>Wow great 🎉, In this blog we have learned about how to take photo and display taken photo using Flutter <strong>camera plugin</strong> and also handled possible issues.Hope this blog is helpfull.</p><blockquote>This article helped you? Long press on the 👏 button as long as you can.</blockquote><blockquote>I got something wrong? Mention it in the comments. I would love to improve.</blockquote><blockquote>I am NavinKumar, Android and Flutter developer. You can find me on <a href="https://www.linkedin.com/in/navin-kumar/">Linkedin</a> or stalk me on <a href="https://github.com/navinkumar0118"><strong>GitHub</strong></a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9c11d282632" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FireBase Authentication]]></title>
            <link>https://navinkumar0118.medium.com/firebase-authentication-8d8478c82bf9?source=rss-baa46aff279------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d8478c82bf9</guid>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Navin Kumar]]></dc:creator>
            <pubDate>Fri, 27 Sep 2019 06:36:15 GMT</pubDate>
            <atom:updated>2019-09-27T07:21:51.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wTwvzvfd2Zq5wAcX1feRTg.png" /></figure><h4>What is FireBase Authentication?</h4><p>Firebase Authentication help Users to login from your app, where Firebase will authenticate users by using their Phone number, Email, Google, Facebook, Twitter and generate unique id for Registered users. It saves lots of time for authenticating and managing every user.</p><h4>Video Demo</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FHZ7aUrnYAt8%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DHZ7aUrnYAt8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FHZ7aUrnYAt8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/72a570dbe45fceae9791fe13692e118f/href">https://medium.com/media/72a570dbe45fceae9791fe13692e118f/href</a></iframe><h4>Overview</h4><ol><li><a href="https://www.codeneuron.com/firebase-authentication/#setup">Firebase setup in Android Studio</a></li><li><a href="https://www.codeneuron.com/firebase-authentication/#register">Registration page</a></li><li><a href="https://www.codeneuron.com/firebase-authentication/#login">Login page</a></li><li><a href="https://www.codeneuron.com/firebase-authentication/#dashboard">Dashboard page</a></li></ol><h3>1. Firebase setup in Android Studio</h3><p>In the previous blog, we learned how to setup firebase in android studio if you want know more, please jump to <a href="https://medium.com/@navinkumar0118/firebase-setup-in-android-studio-64e66001303a">Firebase Setup</a>.</p><ul><li>After creating Project in Firebase console, Getinto the project and select Authentication on the left side.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_HQbCSHv4UnyeGrOw887xQ.png" /></figure><ul><li>Then click “setup new sign-in method” on the sign-in method Tab.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hqJIXnk8S5qNeFqp8hmV9w.png" /></figure><ul><li>Now Enable Email/Password option and save, now users can be authenticated by using their Email and<br>Password.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uSJID8qob888W6INFe35RQ.png" /></figure><h3>2. Registration page</h3><ul><li>Create a project <strong>“MyFirebaseAuth”</strong> in android studio. Rename the MainActivity as <strong>“DashboardActivity”</strong>. This is the first activity called when app launches.</li><li>Add Internet Permission in <strong>Manifest.xml</strong> &lt;uses-permissionandroid:name=&quot;android.permission.INTERNET&quot;/&gt;</li><li>Add below colors in <strong>color.xml</strong></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9fb40949d644d6684925c70ec35c5e0/href">https://medium.com/media/b9fb40949d644d6684925c70ec35c5e0/href</a></iframe><ul><li>Now create an another Activity as <strong>“RegistrationActivity”</strong>, in this activity new users will register their Email and Password.<em>note:(password should contain minimum 6 characters).</em></li><li>Add the below code in your “activity_registration.xml” file. This layout has EditText for getting Email and Password.Button for register.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7b3d4a3215dcb1d2b9ee8b3a1c7fe19/href">https://medium.com/media/f7b3d4a3215dcb1d2b9ee8b3a1c7fe19/href</a></iframe><ul><li>Add the below code in your “Registration.java” file.</li></ul><h4>RegistrationActivity.java</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/169f80149656c526c17d987ad01e1eec/href">https://medium.com/media/169f80149656c526c17d987ad01e1eec/href</a></iframe><ul><li>Firebase provides <strong>createUserWithEmailAndPassword()</strong> method for creating a new User.</li><li>Email and password is passed to this method, firebase will automatically store the user details with unique User UID.</li><li>If Authentication is success, then user is directed to the LoginActivity.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ccac71b0d4bda154f37767f086cabc5/href">https://medium.com/media/2ccac71b0d4bda154f37767f086cabc5/href</a></iframe><h3>3. Login page</h3><ul><li>Create an Activity <strong>“LoginActivity”</strong>, This activity will authenticate the User using their registered Email and Password.</li><li>Add the below code in your “activity_login.xml” file. This layout has EditText for getting Email and Password. Button for Login and Register.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a47a8cec6f1fb218592d18075bf7eecf/href">https://medium.com/media/a47a8cec6f1fb218592d18075bf7eecf/href</a></iframe><ul><li>Add the below code in your “Login.java” file.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/255ab09521797af21b55ff52d83a498c/href">https://medium.com/media/255ab09521797af21b55ff52d83a498c/href</a></iframe><ul><li>Firebase provides <strong>signInWithEmailAndPassword()</strong> method for authenticatingregistered User.</li><li>Email and password is passed to this method, firebase will automatically authenticate the user details, onComplete “task” isSuccess means login is completed. Then User is saved local app storage.</li><li>If Login is success, then user is directed to the DashboardActivity.</li></ul><h3>4. Dashboard page</h3><ul><li>Dashboard activity will display simple Text after successful completion of Login. Hope you already created this activity.</li><li>This activity is called first on app launches, when activity is in onStart state <strong>mAuth.getcurrentUser() </strong>method is called, the recommended way to get the current user is by calling the getCurrentUser method. If no user is signed in, getCurrentUser returns null.</li><li>If currentUser is Null, then it will direct to Loginpage, else Dashboard page is displayed.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85c53da8e3da6a652bd9074791225780/href">https://medium.com/media/85c53da8e3da6a652bd9074791225780/href</a></iframe><ul><li><strong>Logout :</strong></li></ul><p>For Logout process, Firebase reduces lot of time. you can just call it will signout the current user.</p><pre>FirebaseAuth.getInstance().signOut();</pre><ul><li>Create a <strong>menu.xml</strong> file in layout — Menu folder for Logout option.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/240e18eae0f3e8f6773c0e87f054fdc0/href">https://medium.com/media/240e18eae0f3e8f6773c0e87f054fdc0/href</a></iframe><ul><li>Now add below code “DashboardActivity.java”</li></ul><h4>DashboardActivity.java</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fea4624a7cbc61a1d5c5343121958459/href">https://medium.com/media/fea4624a7cbc61a1d5c5343121958459/href</a></iframe><ul><li>After Registering the User details in Registration Activity, Check out in firebase console. The user has been registered successfully.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cgP9tUxoWNCffctcCT_nnQ.png" /></figure><p>Hope this article is helpful, now you can authenticate your app users by using Firebase Authentication.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d8478c82bf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Firebase Setup in Android Studio]]></title>
            <link>https://navinkumar0118.medium.com/firebase-setup-in-android-studio-64e66001303a?source=rss-baa46aff279------2</link>
            <guid isPermaLink="false">https://medium.com/p/64e66001303a</guid>
            <category><![CDATA[google-firebase]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[firebase-integ]]></category>
            <dc:creator><![CDATA[Navin Kumar]]></dc:creator>
            <pubDate>Tue, 17 Sep 2019 14:33:30 GMT</pubDate>
            <atom:updated>2019-09-17T14:41:41.479Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hidQouWvfJ3Zd_lPDR7nGA.png" /></figure><h4>What is Google FireBase?</h4><p>Firebase is a platform to build an application with high quality and in efficient way. It saves lot of time to create backend process. With the help of Firebase we can manage our product in all platforms like Web application, Android and IOS etc. Firebase gives so many useful services like</p><ul><li>Real time database</li><li>Push notification</li><li>Firebase Analytics</li><li>Firebase Authentication</li><li>Firebase Cloud Messaging</li><li>Firebase Storage</li><li>see more <a href="https://firebase.google.com/products/">https://firebase.google.com/products/</a></li></ul><h4>Firebase Setup in Android Studio</h4><ul><li>Create an Android studio project <strong>“MyFirebase”</strong></li><li>Add your gmail account in android studio.(Top right corner in android studio).</li><li>After adding your account, Go to <strong>Tools</strong> and select <strong>Firebase</strong>.(This may vary in future).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sm4M8bce5ncxou8eso_cJQ.png" /></figure><ul><li>Now select <strong>Authentication</strong> on the rightside</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*64PEEsAX_d3Pd7LN4r-4zw.png" /></figure><ul><li>Now click <strong>Connect to firebase</strong> on authentication.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYxIxBLOIh1dzx8FxzX8aw.png" /></figure><ul><li>Now click <strong>Connect to firebase</strong> on popup tab, then firebase is successfully connected.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r1ggcGeLS8KnW12oAlnbCQ.png" /></figure><ul><li>Now click <strong>Add Firebase Authentication</strong> to your app, then select <strong>Accept Changes</strong> on pop up tab.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qa8QhPLEoLvUZwA6z0_Ecw.png" /></figure><p>In case “If !Error occurs: Failed to resolve: firebase-auth-15.0.0.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nl5aTQEeQlfkyWMBzKi4yA.png" /></figure><p>To resolve, Goto build.gradle (module app) file. remove :15.0.0 on the below code.</p><p>implementation ‘com.google.firebase:firebase-auth:16.0.1:15.0.0’</p><p>Add the below code</p><p>implementation ‘com.google.firebase:firebase-auth:16.0.1’</p><ul><li>Now gradle will successfully build</li><li>Now Firebase setup for authentication is completed, we can also add Firebase Cloud Messaging, Analytics, Realtime DB same as above steps.</li><li>Now go to Firebase console <a href="https://console.firebase.google.com/">https://console.firebase.google.com/</a> .Your project has been created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cLk8Rwk5lMNjyk9CiqkzdA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64e66001303a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>