<?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 Sahil Sharma on Medium]]></title>
        <description><![CDATA[Stories by Sahil Sharma on Medium]]></description>
        <link>https://medium.com/@iamgoddamnbatman?source=rss-7bb42f1da657------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*GxIl3ujGv_aBqaJ1zHPBHA.jpeg</url>
            <title>Stories by Sahil Sharma on Medium</title>
            <link>https://medium.com/@iamgoddamnbatman?source=rss-7bb42f1da657------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 07:23:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iamgoddamnbatman/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[The Quick Developer’s Guide for Migrating Apps to Android 12]]></title>
            <link>https://proandroiddev.com/the-quick-developers-guide-to-migrate-their-apps-to-android-12-8656af81aea0?source=rss-7bb42f1da657------2</link>
            <guid isPermaLink="false">https://medium.com/p/8656af81aea0</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-12]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Sahil Sharma]]></dc:creator>
            <pubDate>Sun, 17 Jul 2022 15:18:55 GMT</pubDate>
            <atom:updated>2022-07-18T13:16:51.342Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Quick Developer’s Guide to Migrating Apps to Android 12</h3><h4>Getting your app ready for SplashScreen API, Approximate Location, PendingIntent Mutability and much more …</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VIMW1QvaWGyLVvXI" /><figcaption>Photo by <a href="https://unsplash.com/@abeso?utm_source=medium&amp;utm_medium=referral">Sebastian Bednarek</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Google announced Android 12 (L) on October 2021 and by March 2022 the stable build was released starting with the Pixel phones and soon followed by other major brands.</p><p>Android 12 comes with some big visual and user experience changes, also focusing on Privacy and Performance.</p><p>I thought that this article was necessary as now Google Play Store has enforced to update all the applications to target to API Level 31 (i.e. Android 12) by November 2022 and as I was still getting queries from many of you on how to migrate to Android 12, so here it is!</p><p>In this article, we will quickly start with the important stuff first and later will be reviewing some enhancements that are worth mentioning and deprecations of existing APIs and features.</p><p>So let’s quickly jump to what all changes you need to do to target your application to Android 12 and the things to keep in mind.</p><h4>Safe Export</h4><p>Whenever you define any component (like Activity, Service and Broadcast Receiver) in the manifest, you must have seen/used some thing like &quot;android:exported&quot;</p><p>By default this attribute is set to true, which means that the component can be accessed from outside of your application. For example, If an activity in your app includes intent filters, set this element to “true” to allow other apps to start it.</p><p>From API 31 onward, you have to <strong>explicitly set a value to this attribute</strong>.</p><p>A common rule of thumb is: If the app component includes the <a href="https://developer.android.com/reference/android/content/Intent#CATEGORY_LAUNCHER">LAUNCHER</a> category, set android:exported to true. In most other cases, set android:exported to false.</p><pre>&lt;service android:name=&quot;com.example.app.backgroundService&quot;<br>         android:exported=&quot;false&quot;&gt;<br>    &lt;intent-filter&gt;<br>        &lt;action android:name=&quot;com.example.app.START_BACKGROUND&quot; /&gt;<br>    &lt;/intent-filter&gt;<br>&lt;/service&gt;</pre><p>Failing to do so might throw a compile time:</p><pre>Manifest merger failed : Apps targeting Android 12 and higher are required \<br>to specify an explicit value for android:exported when the corresponding \<br>component has an intent filter defined.</pre><p>Read more about <a href="https://developer.android.com/about/versions/12/behavior-changes-12#exported">Safe Component Exporting</a> and <a href="https://developer.android.com/guide/topics/manifest/activity-element#exported">android:exported</a></p><h4>Pending intents mutability</h4><p>API level 31 onward, you will have to specify the mutability of each <a href="https://developer.android.com/reference/android/app/PendingIntent">PendingIntent</a> object that your app creates.</p><p>To declare that a given PendingIntent object is mutable or immutable, use the <a href="https://developer.android.com/reference/android/app/PendingIntent#FLAG_MUTABLE">PendingIntent.FLAG_MUTABLE</a> or <a href="https://developer.android.com/reference/android/app/PendingIntent#FLAG_IMMUTABLE">PendingIntent.FLAG_IMMUTABLE</a> flag, respectively.</p><pre>val updatedPendingIntent = PendingIntent.getActivity(<br>   applicationContext,<br>   NOTIFICATION_REQUEST_CODE,<br>   updatedIntent,<br>   PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT<br>)</pre><p>Failing to do so the system throws an IllegalArgumentException:</p><pre>PACKAGE_NAME: Targeting S+ (version 31 and above) requires that one of \<br>FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.<br><br>Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if \<br>some functionality depends on the PendingIntent being mutable, e.g. if \<br>it needs to be used with inline replies or bubbles.</pre><h4>Approximate Location</h4><p>Starting in Android 12, users can now chose to provide either Precise location or Approximate Location, even when your app requests the <a href="https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION">ACCESS_FINE_LOCATION</a> runtime permission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*rhDd2c7yU8ndwDfFttSbLA.png" /></figure><p>You will have to handle for both the scenarios now in order to respect users’ privacy, however if your apps use-case is such that requires Precise Location then make sure that the same is prompted to the user and handled in your app accordingly. Read more on <a href="https://developer.android.com/training/location/permissions#upgrade-to-precise">asking for Precise location</a>.</p><p>I recommend that you read the <a href="https://developer.android.com/training/location/permissions">Best Practices on Requesting Location Permissions.</a></p><h4>SplashScreen API</h4><p>Earlier most of us used to create a custom Splash screens by using an Activity or setting a window theme on an Activity.</p><p>If you have previously implemented a custom splash screen in Android 11 or lower, you’ll need to migrate your app to the SplashScreen API to ensure that it displays correctly starting in Android 12.</p><p>On devices running on Android 11, this won’t be a problem but if you have targeted API level 31 and still not migrated to SplashScreen API, the system will throw a Runtime Exception on Android 12 devices.</p><p>It’s also worth noting that the system always applies the new <a href="https://developer.android.com/about/versions/12/features/splash-screen">Android system default splash screen</a> on <a href="https://developer.android.com/topic/performance/vitals/launch-time#cold">cold</a> and <a href="https://developer.android.com/topic/performance/vitals/launch-time#warm">warm starts</a> for all apps. By default, this system default splash screen is constructed using your app’s launcher icon element and the <a href="https://developer.android.com/topic/performance/vitals/launch-time#solutions-3">windowBackground</a> of your theme (if it&#39;s a single color).</p><p>Read about how to <a href="https://developer.android.com/guide/topics/ui/splash-screen/migrate">migrate your existing Splash screen implementation to Android 12 or higher</a></p><p>Read more about <a href="https://developer.android.com/guide/topics/ui/splash-screen">Android Splash Screens</a></p><blockquote>Bonus: Along with the new SplashScreen API, you can also make use of <a href="https://developer.android.com/topic/libraries/app-startup">App Startup library</a> to initialize components at application startup.</blockquote><h4>Exact alarm permission</h4><p>To create an Exact alarm, your app needs have have access to the “Alarms &amp; reminders” capability that appears within the <strong>Special app access</strong> screen in system settings.</p><p>To obtain this special app access, request the <a href="https://developer.android.com/reference/android/Manifest.permission#SCHEDULE_EXACT_ALARM">SCHEDULE_EXACT_ALARM</a> permission in the manifest.</p><p>Failing to do so, system will throw SecurityException.</p><p>But the catch here is that to obtain this special permission and get approval by Google Play store, your app must be of one of the following type:<br>1. Clock or Timer application<br>2. Calendar or Reminder application</p><h4>Web intent resolution</h4><p>Starting in Android 12 (API level 31), your app’s Activity can no longer resolve to generic web intents, the system will redirect them to the default browser, until your app is approved to handle that web intent.</p><p>Read more about <a href="https://developer.android.com/about/versions/12/behavior-changes-all#web-intent-resolution">how your app can get this approval</a>.</p><blockquote>Also read more about <a href="https://developer.android.com/about/versions/12/behavior-changes-12#android-app-links-verification-changes">App Links verification changes</a>.</blockquote><h4>Foreground service launch restrictions</h4><p>Starting from API Level 31, system will throw an Exception if your app tries to trigger a Foreground Service while running in the background.</p><p>However there are few exemptions to that, some of the interesting exemptions are:</p><ul><li>The user turns off battery optimizations for your app. You can help users find this option by sending them to your app’s <strong>App info</strong> page in system settings. To do so, invoke an intent that contains the <a href="https://developer.android.com/reference/android/provider/Settings#ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS">ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS</a> intent action.</li><li>The user performs an action on a UI element related to your app. For example, they might interact with a <a href="https://developer.android.com/guide/topics/ui/bubbles">bubble</a>, <a href="https://developer.android.com/guide/topics/ui/notifiers/notifications">notification</a>, <a href="https://developer.android.com/guide/topics/appwidgets/overview">widget</a>, or activity.</li><li>Your app can <a href="https://developer.android.com/guide/components/activities/background-starts">start an activity from the background</a>, except for the case where the app has an activity in the back stack of an existing task.</li><li>Your app receives a high priority message using <a href="https://firebase.google.com/docs/cloud-messaging">Firebase Cloud Messaging</a>.</li></ul><p>Read about all the <a href="https://developer.android.com/guide/components/foreground-services#background-start-restriction-exemptions">cases where your app can start foreground services even while your app is running in the background.</a></p><h4>Custom notifications</h4><p>If you used Custom Notification in your app, starting from Android 12, notifications with custom content views will no longer use the full notification area; instead, the system applies a standard template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HGZOwaVwSV6Dy2qtpzO6vA.png" /><figcaption>Notification Template. (<a href="https://developer.android.com/about/versions/12/behavior-changes-12#custom-notifications">Source</a>)</figcaption></figure><p>This is to make the notification visually consistent for all apps and in all states like collapsed and expandable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l8FvrSMqOeZnRIgSxPEXeQ.png" /><figcaption>Notification Collapsed and Expanded state. (<a href="https://developer.android.com/about/versions/12/behavior-changes-12#custom-notifications">Source</a>)</figcaption></figure><p>The change in Android 12 affects apps that define custom subclasses of <a href="https://developer.android.com/reference/android/app/Notification.Style">Notification.Style</a>, or which use <a href="https://developer.android.com/reference/android/app/Notification.Builder">Notification.Builder</a>’s methods <a href="https://developer.android.com/reference/android/app/Notification.Builder#setCustomContentView(android.widget.RemoteViews)">setCustomContentView(RemoteViews)</a>, <a href="https://developer.android.com/reference/android/app/Notification.Builder#setCustomBigContentView(android.widget.RemoteViews)">setCustomBigContentView(RemoteViews)</a>, and <a href="https://developer.android.com/reference/android/app/Notification.Builder#setCustomHeadsUpContentView(android.widget.RemoteViews)">setCustomHeadsUpContentView(RemoteViews)</a>.<br>If you are not using the above methods, then you are all good.</p><p>Read more about <a href="https://developer.android.com/about/versions/12/behavior-changes-12#custom-notifications">Custom Notifications</a>.</p><h3>Other improvements/ features worth Mentioning</h3><p>Till now we have covered the main things that you need to migrate your app to Android 12, but there are a few things that you should know.</p><h4>Restricted App Standby Bucket</h4><p>We read about the <a href="https://developer.android.com/topic/performance/appstandby#restricted-bucket">App Standby Buckets</a> before, simply put, these buckets help the system prioritize apps’ requests for resources based on how recently and how frequently the apps are used.</p><p>Now a new App Standby Bucket is introduced: <a href="https://developer.android.com/about/versions/12/behavior-changes-all#restrictive-app-standby-bucket">Restricted</a>.</p><blockquote>According to the documentation, The system considers your app’s behavior, in addition to usage patterns, to decide whether to place your app in the restricted bucket. Your app is less likely to be placed in the restricted bucket if your app uses system resources more responsibly. Also, the system places your app in a less restrictive bucket if the user interacts directly with your app.</blockquote><p>Read more about <a href="https://developer.android.com/about/versions/12/behavior-changes-all#restrictive-app-standby-bucket">Restricted App Standby Bucket</a>.</p><h4><strong>Microphone and camera indicators and toggle</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*Qt64SsAVNgTlOYz5NLZkBQ.png" /><figcaption>Camera and Microphone indicators on the status bar. (<a href="https://developer.android.com/about/versions/12/behavior-changes-all#mic-camera-indicators">Source</a>)</figcaption></figure><p>Just like in Apple products, Android too has this feature now where you will get to see an indicator on the status bar whenever your device’s Camera or Microphone is in use.</p><p>Also, supported devices that run Android 12 or higher allow users to enable and disable camera and microphone access for all apps on the device, by pressing a single toggle option.</p><p>Read more about the <a href="https://developer.android.com/training/permissions/explaining-access">best practices to access to more sensitive permissions</a>.</p><h3>Deprecations</h3><h4>Root launcher activities are no longer finished on Back press</h4><p>If your activity is the root activity (ie. the last activity on the task stack), on press of the back button, it wont be killed but simply put to background. Just like how the press the home button.</p><p>This change means that users who use Back to navigate out of your app are able to more quickly resume your app from a <a href="https://developer.android.com/topic/performance/vitals/launch-time#warm">warm state</a>, instead of having to completely restart the app from a <a href="https://developer.android.com/topic/performance/vitals/launch-time#cold">cold state</a>.</p><p>Also, it is recommended using the AndroidX Activity APIs for <a href="https://developer.android.com/guide/navigation/navigation-custom-back">providing custom back navigation</a>, rather than overriding onBackPressed()</p><p>Read <a href="https://developer.android.com/about/versions/12/behavior-changes-all#back-press">more about this</a>.</p><h4><strong>Bouncy Castle implementation removed</strong></h4><p>Android 12 removes many <a href="https://www.bouncycastle.org/">BouncyCastle</a> implementations of cryptographic algorithms that were previously deprecated, including all AES algorithms. The system instead uses the <a href="https://github.com/google/conscrypt">Conscrypt</a> implementations of these algorithms.</p><p>Read <a href="https://developer.android.com/about/versions/12/behavior-changes-all#bouncy-castle">more about this</a>.</p><h4>Display#getRealSize and getRealMetrics : deprecated</h4><p>The following methods are <strong>deprecated</strong>:</p><ul><li><a href="https://developer.android.com/reference/android/view/Display#getSize(android.graphics.Point)">Display.getSize()</a> — Deprecated: Android 11 onward</li><li><a href="https://developer.android.com/reference/android/view/Display#getMetrics(android.util.DisplayMetrics)">Display.getMetrics()</a> — Deprecated:Android 11 onward</li><li><a href="https://developer.android.com/reference/android/view/Display#getRealSize(android.graphics.Point)">Display.getRealSize()</a> — Deprecated:Android <strong>12</strong> onward</li><li><a href="https://developer.android.com/reference/android/view/Display#getRealMetrics(android.util.DisplayMetrics)">Display.getRealMetrics()</a> — Deprecated:Android <strong>12</strong> onward</li></ul><p>Instead of these methods it is recommended to use the Jetpack <a href="https://developer.android.com/jetpack/androidx/releases/window">WindowManager</a> library, which includes a <a href="https://developer.android.com/reference/androidx/window/layout/WindowMetrics">WindowMetrics</a> class that supports Android 4.0 (API level 14) and higher.</p><h4>Apps can’t close system dialogs</h4><p>Starting with Android 12, you won’t be able to close system dialogs as the <a href="https://developer.android.com/reference/android/content/Intent#ACTION_CLOSE_SYSTEM_DIALOGS">ACTION_CLOSE_SYSTEM_DIALOGS</a> intent action is deprecated. If you try to launch this intent, the system will simply throw a SecurityException . On Android 11 devices, the system will ignore the intent.</p><p>However there are few special cases, Read more about this <a href="https://developer.android.com/about/versions/12/behavior-changes-all#close-system-dialogs">change</a>.</p><h3>References</h3><ul><li><a href="https://www.android.com/intl/en_in/android-12/">About Android 12</a></li><li><a href="https://developer.android.com/about/versions/12/migration">Migrate Apps to Android 12</a></li><li>Behavior changes in Android 12 for <a href="https://developer.android.com/about/versions/12/behavior-changes-all">All apps</a> and for <a href="https://developer.android.com/about/versions/12/behavior-changes-12">apps targeting Android 12</a>.</li><li><a href="https://support.google.com/googleplay/android-developer/answer/11926878?hl=en">Target API level requirements for Google Play apps</a></li></ul><h3>Parting Words</h3><p>Let me know your suggestions and if you think I missed mentioning an important change in Android 12.</p><p>Now that you know everything to migrate your amazing app to Android 12, what are you waiting for?</p><p>See you next time.</p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8656af81aea0" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/the-quick-developers-guide-to-migrate-their-apps-to-android-12-8656af81aea0">The Quick Developer’s Guide for Migrating Apps to Android 12</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Reasons Why I Am Excited About the Release of iOS 15]]></title>
            <link>https://medium.com/geekculture/10-reasons-why-i-am-excited-about-the-release-of-ios-15-bab5183f7824?source=rss-7bb42f1da657------2</link>
            <guid isPermaLink="false">https://medium.com/p/bab5183f7824</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[smartphones]]></category>
            <category><![CDATA[iphone]]></category>
            <category><![CDATA[ios-15-beta]]></category>
            <dc:creator><![CDATA[Sahil Sharma]]></dc:creator>
            <pubDate>Wed, 15 Sep 2021 11:32:55 GMT</pubDate>
            <atom:updated>2021-09-15T11:32:55.353Z</atom:updated>
            <content:encoded><![CDATA[<h4>What&#39;s new in iOS 15? Focus Mode, Share Play, and more…</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uXB6bVMqxjOi1fi7" /><figcaption>Photo by <a href="https://unsplash.com/@davidgrdm?utm_source=medium&amp;utm_medium=referral">David Grandmougin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I have been a Symbian user for Six years, and an Android user for almost Eight years, I have been using Apple products for quite a long, but this time I chose iPhone as my primary mobile phone. It was a well-thought decision, and I have no hesitation to say that I am really happy with this decision. I believe that Apple products are well thought of and are really focused on User Experience. The way all their apps works in synchronization with the OS and the way all the devices are so well connected with each other, I don’t think I could ever get this experience in an Android Phone.<br>Anyways, this article is not about comparing platforms. It’s about why I am specifically excited about the release of iOS 15.</p><p>Whenever we talk about Apple products, there are 2 things that come to our mind — Great User Experience and Privacy. And lately, I take these 2 things very seriously. I remember the days when I used to unlock my previous phone in the morning and there would be around more than 50 notifications suddenly pop up from various applications and none of them were actually of any use. Or many many services spamming me on an hourly basis. This time I am very much concerned about my privacy and peace of mind.</p><p>Also since last year, 2020, with the ongoing Coronavirus pandemic, we are locked in our homes. Most of us in the I.T. domain are working remotely. Some of our friends are working from their native places. I see a very important role of collaborative tools here, tools like Zoom, Meet, and IMs have really helped us to bridge that gap.</p><p>Keeping all these things in mind, let see what we got in iOS 15.</p><p>If you go by the website of iOS 15 preview, there are tons of new features and enhancements. But let’s see which feature I am most excited about and why.</p><h3>1. Share Play</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B31aLMjQjJVdzdPah88FEw.png" /><figcaption>Source: <a href="https://www.apple.com/in/ios/ios-15-preview/">Apple’s official website</a></figcaption></figure><p>Yes, I know that Share Play is delayed and won’t be part of the initial public release. But it’s gonna be there for sure, probably in the future minor releases. With all of us in lockdown mode right now, our friends and loved ones being distant from us, I think Share Play is the need of the hour.<br>How cool is it that you and your friends who have not met for months can now all connect, watch a movie together while you can chat? It’s almost like watching a show/ movie/ sports (whatever you like) on a day out with friends, no matter wherever you are.<br>I and my friends are super excited about this feature.</p><h3>2. Improved FaceTime</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gAq1_Biw7JtTKF1lQqnN5A.png" /><figcaption>Source: <a href="https://www.apple.com/in/ios/ios-15-preview/">Apple’s official website</a></figcaption></figure><p>First of all how the new FaceTime is the game-changer? Again as all of us are in lockdown mode right now, we are all dependent on Video Conference tools like Zoom or Google Meet to communicate virtually. This has introduced a new set of challenges for people working from home. They have kids running all across the house, there are neighbors who are drilling and grinding every now and then, there is a Football match going on and people are going crazy all over the house, right?<br>The new FaceTime features like Voice Isolation so that you can filter out the background noise and the Portrait mode so you can filter the background image are the lifesavers.</p><p>I live in India and a majority of the people here use an Android phone. What do I do with FaceTime when none of my friends are using it? — Well not anymore. You can share a FaceTime link with everyone now. No matter Android, Windows, or whatever, you just need a web browser to connect. You can even create a Calendar invite and attach a FaceTime link to it so that everyone knows where to connect.</p><p>Apple has now entered the game.</p><h3>3. Focus Mode</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-UanYAG8mZxZ-uLOPr5U9w.png" /><figcaption>Source: <a href="https://www.apple.com/in/ios/ios-15-preview/">Apple’s official website</a></figcaption></figure><p>As I told above that I really want my phone to respect my peace of mind. On a busy day or while in a meeting, the phone bombarding you with irrelevant stuff is an utter nightmare. Moreover, sometimes you just don’t want any distractions. Watching a suspense thriller on Netflix and me getting 100 messages because my friends in my friend’s group are going bizarre over something stupid, is not what I want at that movement. Or imagine you are concentrating on something important and getting buzzed by promotional messages every 15 minutes is not what I want. But yes, I may want some urgent messages, calls, or certain services to interrupt and notify me.</p><p>The focus mode lets you focus on what’s important at the moment. You can choose which apps and widgets appear on the home screen and which apps to send you the notifications. It is an advance Do Not Disturb mode basically.</p><p>You can create several Focus mode profiles, like Driving, Yoga, In a Meeting, etc whatever you want and how to want it to work.<br>That’s is a pretty cool and powerful feature which will help you to be more productive.</p><h3>4. Improved Notifications</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PzSelbHRTr9M5YKGHev8_w.png" /><figcaption>Source: <a href="https://www.apple.com/in/ios/ios-15-preview/">Apple’s official website</a></figcaption></figure><p>With the Focus mode discussed above, you will surely miss the Notifications which might have been not relevant during the work hours but you don’t mind getting those later that day. For example, Money Heist season 5 is now available on Netflix. Apple has a smart solution for it — Notification Summary.<br>Receive a helpful summary of your notifications delivered daily, in the morning and evening, or scheduled at a time you choose. Your summary is personalized and helps you quickly catch up on what you missed while away focusing.<br>This is really cool and will contribute towards Productivity.</p><p>Moreover, if you just want a particular app or message thread to not send you any notifications, and Focus or Do not Disturb is overkill here, you can just simply Mute an app or message thread temporarily.</p><h3>5. Web Extensions on iOS Safari</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7q-2FqMLfdS1KUL0m2Y-8Q.png" /><figcaption>Source: <a href="https://www.apple.com/in/ios/ios-15-preview/">Apple’s official website</a></figcaption></figure><p>Web extensions can add functionality and features to Safari. Just like your Mac, now you will get Extensions (Plugins) on iOS Safari as well. I am obsessed with Dark themes everywhere. Almost all apps these days support Dark Theme these days. But what about the Websites? Not every website comes with a Dark Theme, browsing in the dark ambiance for hours can almost burn your eyes.</p><p>I use an Extension called <a href="https://darkreader.org/">Dark Reader</a> of my MacBook Safari. It colors every website Dark and you can fully customize the appearance with various options and filters that it provides.</p><p>I am really excited that plugins like these can be applied on my phone’s Safari as well.</p><h3>6. Live Text and Visual Lookup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*igB-ACJesXhFfSTb4IQCPA.png" /><figcaption>Source: <a href="https://www.apple.com/in/ios/ios-15-preview/">Apple’s official website</a></figcaption></figure><p>Text is now completely interactive in all your photos, so you can use functions like copy and paste, lookup, and translate. Live Text works in Photos, Screenshot, Quick Look, and Safari and in live previews with Camera. Which is very cool, right?</p><p>Every now and then, I find myself in situations where I have to copy a text from the photo and end up typing it manually. Or say if I have to lookup an object in the photo, I have to ask a friend about it. Well, now my Photos app can do that by default. Amazing!</p><h3>7. Improved Spotlight search</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rVLLSrMWeH5ycJQQKSH1cA.png" /><figcaption>Source: <a href="https://www.apple.com/in/ios/ios-15-preview/">Apple’s official website</a></figcaption></figure><p>Spotlight Search is really smart and handy for finding anything you need on your iPhone. Well, Spotlight search can now show richer search results from the web, it can search your photos as well for that keyword, you can easily search People, Monuments, Animals, or objects.</p><p>Additionally, now you can simply pull down Spotlight search from your lock screen as well.</p><h3>8. App Privacy Report</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SwbZT2egfDzi4T9tGRD-WA.png" /><figcaption>Source: <a href="https://www.apple.com/in/ios/ios-15-preview/">Apple’s official website</a></figcaption></figure><p>App Privacy Report is a section in Settings that lets you see how often apps have accessed your location, photos, camera, microphone, and contacts during the last seven days. It also shows you which apps have contacted other domains and how recently they have contacted them. <br>This will give you a transparent picture of which app is doing what, and how often.</p><p>I think it is a big step towards transparency and will let you decide that It’s time to taken action against which app.</p><h3>9. Siri with Offline support</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kJfq8uWli2cUV6Az2H2zg.png" /><figcaption>Source: <a href="https://www.apple.com/in/ios/ios-15-preview/">Apple’s official website</a></figcaption></figure><p>There are times when we summon Siri to do something and after taking a while, Siri says that it needs an active Internet connection to process your request, making you like a fool. Siri can now process many types of requests offline without an internet connection, including Timers &amp; Alarms, Phone, Messaging, Sharing, App Launch, Control Audio Playback, and Settings. Also, Processing on the device means that Siri is incredibly fast. There are other improvements in Siri as well which makes Siri smarter than before.</p><h3>10. iCloud+ Privacy features</h3><p>Everyone is eyeing the new iCloud features like Private Rely and Hide My Email.<br>According to Apple, iCloud Private Relay is a service that lets you connect to virtually any network and browse with Safari in an even more secure and private way. It ensures that the traffic leaving your device is encrypted so no one can intercept and read it. Then all your requests are sent through two separate internet relays. It’s designed so that no one — including Apple — can use your IP address, location, and browsing activity to create a detailed profile about you.<br>How cool is that!</p><h3>That’s all!</h3><p>Although there are many more enhancements in the OS and the apps as well, these were the top features/enhancements that I am really excited about. Worth mentioning that with new Memojis you can now choose new outfits and accessories. :)</p><p>Read a list of all the upcoming features in iOS 15 from <a href="https://www.apple.com/ios/ios-15-preview/features/">Apple’s iOS 15 official website</a>.</p><p>I am very excited about the Apple event on 14th September 2021 and expecting iOS 15 to start rollout after a week, or two, following the event.</p><p>Which feature are you most excited about? Write down in the comments.</p><p>Cheers !!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bab5183f7824" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/10-reasons-why-i-am-excited-about-the-release-of-ios-15-bab5183f7824">10 Reasons Why I Am Excited About the Release of iOS 15</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Quick Developers Guide to Migrate Their Apps to Android 11]]></title>
            <link>https://proandroiddev.com/the-quick-developers-guide-to-migrate-their-apps-to-android-11-e4ca2b011176?source=rss-7bb42f1da657------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4ca2b011176</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[android-11]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Sahil Sharma]]></dc:creator>
            <pubDate>Wed, 23 Dec 2020 15:16:54 GMT</pubDate>
            <atom:updated>2020-12-23T15:16:54.974Z</atom:updated>
            <content:encoded><![CDATA[<h4>Getting your app ready for Scoped Storage, Package Visibility, Permission changes, and much more…</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ta9b9Zo8cuI3u9E-" /><figcaption>Photo by <a href="https://unsplash.com/@mbaumi?utm_source=medium&amp;utm_medium=referral">Mika Baumeister</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Android 11 has been launched already and is soon to be released on Android phones from most of the major manufactures. Android 11 is much awaited with features like Enhanced 5G Support, Native Screen Recorder, Notifications Priority Conversations, Notification Chat Bubble, and many privacy enhancements like Scoped Storage and Package Visibility.</p><p>Most of the apps are already ready to rock Android 11, but for some of you who have still not acknowledged this change, it is high time and this article is specifically for you.</p><p>In this article, we will quickly start with the important stuff first and later will be reviewing some good-to-have enhancements and deprecations of existing APIs and features.</p><p>So without further ado, let&#39;s quickly review what Android 11 got for us.</p><h3>Foreground Service Type</h3><p>If your app targets Android 11 (API level 30) or higher and accesses the camera or microphone in a foreground service, then you will have to declare the camera or microphone foreground service types, respectively, as attributes of your &lt;service&gt; component.</p><pre>&lt;manifest&gt;<br>    ...<br>    &lt;service ...<br>        android:foregroundServiceType=&quot;location|camera|microphone&quot; /&gt;<br>&lt;/manifest&gt;</pre><h4>Add foreground service types of Work Manager Workers</h4><p>Similar to foreground services, if you have a long-running worker that requires access to location, camera, or microphone, then you need to declare the worker’s foreground service type in your app’s manifest.</p><pre>&lt;service<br> android:name=&quot;androidx.work.impl.foreground.SystemForegroundService&quot;<br>    android:foregroundServiceType=&quot;location|camera|microphone&quot;<br>    tools:node=&quot;merge&quot; /&gt;</pre><p>Note the Service name here.</p><pre>android:name=”androidx.work.impl.foreground.SystemForegroundService”</pre><p>To learn more, refer to “<a href="https://developer.android.com/topic/libraries/architecture/workmanager/advanced/long-running#kotlin">Support for long-running workers</a>”.</p><h3>Background Location Permission</h3><p>In the previous version of Android, ie. Android 10, we need to ask for Background Location permission in order for our app to access the location in the background.</p><p>In Android 11, it is taking one step further as now Background Permission cannot be given access before the Foreground Location Permission.</p><p>That means Foreground and Background Location Permissions cannot be requested together. If you request a foreground location permission and the background location permission at the same time, the system ignores the request and doesn’t grant your app either permission.</p><p>Another important point to note is that beginning with Android 11, the system dialog doesn’t include the <strong>Allow all the time</strong> option. Instead, users must enable the background location from the app’s settings page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*vOU6WtRmqJwJwTiSe6u4vw.png" /><figcaption>App’s Settings page</figcaption></figure><h3>Other enhancements in Permissions</h3><h4>One-Time Permissions</h4><p>Considering the User’s Privacy in mind, whenever your app requests permission related to location, microphone, or camera, Android now gives the option to the user to allow permission only once. This means as soon as your app gets killed, all the One-Time permissions will be revoked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*SFVIlJZfF8XP2p59wmjWKg.png" /><figcaption>Permission Dialog in Android 11, with Background Location Permission request</figcaption></figure><p>Some Important points here to keep in mind are:</p><ul><li>It is applicable only for Runtime permissions.</li><li>If the user sends your app to the background, your app can continue to access the data for a short period of time.</li><li>If you launch a foreground service while the activity is visible, and the user then moves your app to the background, your app can continue to access the data until that foreground service stops. And even if the user enters the activity again while the foreground service was running, then the granted permission will remain accessible.</li></ul><p>Although for One-Time Permission you don&#39;t have to handle anything in your code, it is still worth mentioning, as it may affect your existing functionality especially if you are not following the <a href="https://developer.android.com/training/permissions/requesting#one-time">best practices</a> for requesting location permissions.</p><h4>The system can Auto Revoke permissions from unused apps</h4><p>If your app targets Android 11 or higher and isn’t used for a few months, the system protects user data by automatically resetting the sensitive runtime permissions that the user had granted your app.</p><p>Auto Revoked Permissions can be disabled from the app’s settings page, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*1QT4oa_ynaymqhUTqfGEDA.png" /></figure><p>Alternatively, you can request the user to disable it by sending him to the permissions page, using action Intent.<em>ACTION_AUTO_REVOKE_PERMISSIONS</em></p><blockquote><em>Y̵o̵u̵ ̵c̵a̵n̵ ̵a̵l̵s̵o̵ ̵c̵o̵n̵f̵i̵g̵u̵r̵e̵ ̵A̵u̵t̵o̵ ̵R̵e̵v̵o̵k̵e̵ ̵P̵e̵r̵m̵i̵s̵s̵i̵o̵n̵s̵ ̵p̵r̵o̵g̵r̵a̵m̵m̵a̵t̵i̵c̵a̵l̵l̵y̵ ̵b̵y̵ ̵u̵s̵i̵n̵g̵ ̵</em><em>a̵n̵d̵r̵o̵i̵d̵:̵a̵u̵t̵o̵R̵e̵v̵o̵k̵e̵P̵e̵r̵m̵i̵s̵s̵i̵o̵n̵s̵ ̵a̵t̵t̵r̵i̵b̵u̵t̵e̵ ̵i̵n̵ ̵y̵o̵u̵r̵ ̵a̵p̵p̵s̵ ̵M̵a̵n̵i̵f̵e̵s̵t̵ ̵f̵i̵l̵e̵.̵ <br>Note that the </em><em>android:autoRevokePermission attribute is no longer used and will do nothing.</em></blockquote><p>Further, you can programmatically check if Auto Revoke Permissions are whitelisted or not</p><pre>public boolean PackageManager#isAutoRevokeWhitelisted ()</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e920713fd03cc32d8689313b9c09b83/href">https://medium.com/media/5e920713fd03cc32d8689313b9c09b83/href</a></iframe><h4>Permission Dialog Visibility</h4><p>Repeated denial of runtime permission by the user will imply “Don’t ask again”. The system then will no longer prompt the user with the permission dialog and you have to request the user to grant permission from the apps settings page.</p><p>Make sure you are already following the <a href="https://developer.android.com/training/permissions/requesting">best practices to request runtime permissions.</a></p><h3>Scoped Storage</h3><p>Scoped Storage was first introduced in Android 10, to give users more control over their files and to limit file clutter. What Scoped Storage really is, simply, instead of giving the app permission to view/modify whole external storage, give it access only to the app-specific directory on external storage, as well as specific types of media that the app has created.</p><p>Scoped Storage is necessary to —</p><ul><li>protect the user’s data</li><li>prevent apps from scattering files all over the disc</li><li>delete junk app files when that app is uninstalled</li></ul><p>By introducing Scoped Storage, they separated storage into collections and limiting broad access to shared storage. Storage is divided into:</p><ul><li>Apps Private Storage — Internal or External storage accessible only by your app.</li><li>Shared Storage — With is further categorized into Photos, Videos, Audio, and Downloads.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*c7cd9S5J5vLXMf3hhwtvMg.png" /><figcaption>Source: Google</figcaption></figure><p>In Android 10 scoped storage was very controversial and thankfully optional.<br>But this is not the case with Android 11. With some changes to it, Scoped Storage is now mandatory for Android 11.</p><p>Luckily, in Android 11, apart from <a href="https://developer.android.com/reference/android/provider/MediaStore">MediaStore</a> APIs, we can use</p><ul><li>Regular Java’s<a href="https://developer.android.com/reference/java/io/File">File</a> API (with is internally delegated to <a href="https://developer.android.com/reference/android/provider/MediaStore">MediaStore</a> API)</li><li>Native libraries, such as fopen().</li></ul><p>Modifying the media files is not as same as before, you require the user’s consent for that. Using createWriteRequest() and createDeleteRequest() you can write and delete the media file respectively. Both methods support modifying multiple files (Bulk Operation) at the same time with a single request.</p><p>Also, two new Media Store concepts are introduced:</p><ul><li>Trash — Similar to a Recycle bin on Windows OS, where you can restore the media files or else they will be deleted permanently after some time. This can be achieved usingcreateTrashRequest().</li><li>Favorites — Media files can be marked favorites by the user. This can be achieved usingcreateFavoriteRequest().</li></ul><p>If your app still has files stored outside of the app and your app targets API level 29, use the <a href="https://developer.android.com/reference/android/R.attr#requestLegacyExternalStorage"><em>requestLegacyExternalStorage</em></a><em> </em>attribute and migrate your files to the app directory.</p><blockquote>Apps that run on Android 11 but target Android 10 (API level 29) can still request the <a href="https://developer.android.com/reference/android/R.attr#requestLegacyExternalStorage"><em>requestLegacyExternalStorage</em></a> attribute.</blockquote><p>Refer to this helpful tutorial by Raywanderlitch: <a href="https://www.raywenderlich.com/10768834-scoped-storage-tutorial-for-android-11-deep-dive">“Scoped Storage Tutorial for Android 11: Deep Dive”</a> to help you get started with the Scoped Storage and alternatively you can refer to <a href="https://developer.android.com/about/versions/11/privacy/storage">“Storage updates in Android 11”</a> from the official Android Documentation.</p><h3>Package Visibility</h3><p>Earlier, apps could query the full list of installed apps on the system using methods like queryIntentActivities(). Mostly, I was far broader access you what you actually require.</p><p>With Android 11, this is no longer the case. Using the &lt;queries&gt; element, apps can define the set of other packages that they can access. This element helps encourage the principle of least privilege by telling the system which other packages to make visible to your app.</p><p>If your app targets Android 11 or higher, you might need to add the &lt;queries&gt; element in your app&#39;s manifest file. Within the &lt;queries&gt; element, you can specify packages by name, by intent signature, or by provider authority.</p><pre>&lt;manifest package=&quot;com.example.myapp&quot;&gt;<br>  &lt;queries&gt;</pre><pre>    &lt;!-- Specific apps you interact with, eg: --&gt;<br>    &lt;package android:name=&quot;com.example.store&quot; /&gt;<br>    &lt;package android:name=&quot;com.example.maps&quot; /&gt;    <br>    <br>    &lt;!--<br>         Specific intents you query for,<br>         eg: for a custom share UI<br>    --&gt;<br>    &lt;intent&gt;<br>      &lt;action android:name=&quot;android.intent.action.SEND&quot; /&gt;<br>      &lt;data android:mimeType=&quot;image/png&quot; /&gt;<br>    &lt;/intent&gt;</pre><pre>  &lt;/queries&gt;<br>  ...<br>&lt;/manifest&gt;</pre><h4>Example</h4><p>Suppose you want to send an email, you have to create an <a href="https://developer.android.com/reference/android/content/Intent">Intent</a> for it and let the system find an appropriate app to handle the request.</p><pre>val intent = Intent().<em>apply </em><strong>{<br>    </strong><em>action </em>= Intent.<em>ACTION_SENDTO<br>    data </em>= (Uri.parse(&quot;mailto:recipient@example.com&quot;))<br>    putExtra(Intent.<em>EXTRA_EMAIL</em>, &quot;Hi! How are you?&quot;)<br>    putExtra(Intent.<em>EXTRA_SUBJECT</em>, &quot;Testing Package Visibility&quot;)<br><strong>}</strong></pre><pre>startActivity(intent)</pre><p>This code will work fine (even on the API level 30) if the email app is installed on the device. But what if there are no apps that can handle this request? — The app will crash by throwing <a href="https://developer.android.com/reference/android/content/ActivityNotFoundException?hl=en">ActivityNotFoundException</a>.</p><p>A safe option is to first check that if we have at least one app which can handle this request. So we could do something like:</p><pre><em>// It will always return null on Android 11, unless &lt;queries&gt; specified in manifest!</em></pre><pre>if (<em>intent</em>.resolveActivity(<em>packageManager</em>) == null) {<br>    toast(&quot;No app found to handle this request&quot;)<br>} else {<br>    startActivity(<em>intent</em>)<br>}</pre><p>Now, this is where your code will <strong>fail</strong>, as your app is not allowed to query other installed apps. Here, in order for your code to work, you will have to add &lt;queries&gt; in your app’s manifest file and declare your intent.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00e0a9d6a1bf56300327e6970addeafa/href">https://medium.com/media/00e0a9d6a1bf56300327e6970addeafa/href</a></iframe><h4>Custom Tabs</h4><p>When using <a href="https://developers.google.com/web/android/custom-tabs">Custom Tabs</a> to open a Web URL, it is possible that there may be some non-browser apps that can also handle that URL. It is recommended that you allow the non-browser app to handle that URL first.</p><p><a href="https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_REQUIRE_NON_BROWSER">FLAG_ACTIVITY_REQUIRE_NON_BROWSER</a> can be used here to query Non-Browser apps only.</p><p>To learn more about it, refer to “<a href="https://developer.android.com/training/basics/intents/package-visibility-use-cases">Configuring package visibility based on use cases</a>” from Android Documentation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a41ed9f82ca14291b398b1ca56cc03f1/href">https://medium.com/media/a41ed9f82ca14291b398b1ca56cc03f1/href</a></iframe><h4>Important Point</h4><p>The system makes <a href="https://developer.android.com/training/basics/intents/package-visibility#automatic">some apps visible to your app automatically</a>, but it hides other apps by default. Generally, these are apps that are linked to your app in some ways, like, Any app that starts or binds to a service in your app, access a content provider in your app, whose content provider your app accesses, etc.</p><blockquote>You can start another app’s activity using either an <a href="https://developer.android.com/guide/components/intents-filters#ExampleSend">implicit</a> or <a href="https://developer.android.com/guide/components/intents-filters#ExampleExplicit">explicit</a> intent, regardless of whether that other app is visible to your app. You just cannot query the intent.</blockquote><h4>What do I do if my App is an App Launcher or similar, where I need to know all the apps that are installed on the device?</h4><p>To allow your app to see all other installed apps, the system provides the <a href="https://developer.android.com/reference/kotlin/android/Manifest.permission#query_all_packages">QUERY_ALL_PACKAGES</a> permission.</p><pre>&lt;uses-permission android:name=&quot;android.permission.QUERY_ALL_PACKAGES&quot;/&gt;</pre><p>This permission is appropriate for apps that genuinely need this permission like a Launcher App, a Security App, Device Management App, Accessibility App, etc.</p><blockquote>In an upcoming policy update, look for Google Play to provide guidelines for apps that need the QUERY_ALL_PACKAGES permission.</blockquote><h3>Good-to-Have Enhancements</h3><h4>Notifications</h4><p>Notifications now have support for Priority conversations and native chat bubbles, and sending images right from the notification panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*w9X2YJA14gEJFmCcILxLug.gif" /></figure><p>Conversations notifications are styled differently from other Non-Conversation notifications with a strong emphasis on the avatar representing people combined with the app carrying the conversation. These notifications bring some actions like marking this conversation as a priority, promoting this conversation as a <a href="https://developer.android.com/guide/topics/ui/bubbles">bubble</a>, setting custom sounds or vibrations, or simply silencing the notification.</p><p>To learn more about Conversation Space, <a href="https://developer.android.com/reference/androidx/core/app/NotificationCompat.MessagingStyle">MessagingStyle</a>, and the Chat Bubble, refer to “<a href="https://developer.android.com/guide/topics/ui/conversations">People and conversations</a>” from Android Documentation.</p><h4><strong>Synchronized IME transitions</strong></h4><p>New APIs let you synchronize your app’s UI with the IME (input method editor, or on-screen keyboard) and system bars as they animate on and offscreen, making it much easier to create natural, intuitive, and jank-free IME transitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*JizlM8NuJAsjAmujT3LJcw.gif" /></figure><p>The new <a href="https://developer.android.com/reference/android/view/WindowInsetsAnimation.Callback">WindowInsetsAnimation.Callback</a> API notifies apps of per-frame changes to insets while the system bars or the IME animate.</p><p>And moreover, finally, a question that was being asked for decades “How to check if On-Screen Keyboard is visible” can now finally be answered.</p><p><a href="https://medium.com/androiddevelopers/animating-your-keyboard-fb776a8fb66d">Read more</a> about it in this detailed, amazing article by <a href="https://medium.com/u/9303277cb6db">Chris Banes</a>.</p><h3>Deprecations</h3><h4>Async Task is deprecated</h4><p>Starting from API level 30 <a href="https://developer.android.com/reference/android/os/AsyncTask">AsyncTask</a> is deprecated. It means you can still use it in your code, but it is no longer a recommended approach and you should soon migrate to java.util.concurrent or <a href="https://developer.android.com/topic/libraries/architecture/coroutines">Kotlin concurrency utilities</a> (Kotlin Coroutines) instead.</p><p>Android is now Kotlin first and it is very strongly recommended to use Kotlin Coroutines for such tasks.</p><h4>The Non-Looper constructor of Handler is deprecated</h4><p><a href="https://developer.android.com/reference/android/os/Handler#Handler()">Handler</a>() and <a href="https://developer.android.com/reference/android/os/Handler#Handler(android.os.Handler.Callback)">Handler</a>(<a href="https://developer.android.com/reference/android/os/Handler.Callback">Handler.Callback</a> callback) are deprecated because they do not specify a <a href="https://developer.android.com/reference/android/os/Looper">Looper</a>, which can cause bugs, for example, mistakingly specifying a Handler on a thread without an active looper will cause your app to crash.</p><p>Android recommends explicitly passing a <a href="https://developer.android.com/reference/android/os/Looper">Looper</a> to the Handler using these constructors: <a href="https://developer.android.com/reference/android/os/Handler#Handler(android.os.Looper)">Handler</a>(<a href="https://developer.android.com/reference/android/os/Looper">Looper</a> looper) and <a href="https://developer.android.com/reference/android/os/Handler#Handler(android.os.Looper,%20android.os.Handler.Callback)">Handler</a>(<a href="https://developer.android.com/reference/android/os/Looper">Looper</a> looper, <a href="https://developer.android.com/reference/android/os/Handler.Callback">Handler.Callback</a> callback)</p><pre>val mHandler: Handler = Handler(Looper.getMainLooper())</pre><h4>Custom Toast Views are deprecated</h4><p>ie. <a href="https://developer.android.com/reference/android/widget/Toast?hl=en#setView(android.view.View)">Toast#setView</a> and <a href="https://developer.android.com/reference/android/widget/Toast?hl=en#getView()">Toast#getView</a> methods are now deprecated. Apps can create a standard text toast or use a <a href="https://developer.android.com/reference/com/google/android/material/snackbar/Snackbar">Snackbar</a> when in the foreground.</p><p>Also in order to make the UI consistent, starting from API level 30, <strong>custom toast messages will not be displayed while the app is in the background.</strong></p><p>Another important thing here is that although <a href="https://developer.android.com/reference/android/widget/Toast#setMargin(float,%20float)">Toast#setMargin</a> and <a href="https://developer.android.com/reference/android/widget/Toast#setGravity(int,%20int,%20int)">Toast#setGravity</a> are not deprecated, but these methods are a no-op when called on text toasts. However, they work fine with simple toasts.</p><blockquote>A “Simple Toast” is a toast constructed from Toast(context: Context) whereas a “Text Toast” is a toast constructed from the static method Toast(context: Context, text: CharSequence, duration: Int)</blockquote><h3>References</h3><ul><li><a href="https://www.android.com/android-11/">About Android 11</a></li><li><a href="https://developer.android.com/about/versions/11">What’s in Android 11 — For Developers</a></li><li><a href="https://android-developers.googleblog.com/2020/09/android11-final-release.html">Quick Glance at What’s New in Android 11</a></li><li><a href="https://developer.android.com/about/versions/11/migration">Migrating Apps to Android 11</a></li></ul><h3>Parting Words</h3><p>Let me know your suggestions and if you think I missed mentioning an important change in Android 11.</p><p>Now that you know everything to migrate your amazing app to Android 11, what are you waiting for?</p><p>I got to decorate my Christmas Tree now — Merry Christmas to all. 🎄</p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4ca2b011176" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/the-quick-developers-guide-to-migrate-their-apps-to-android-11-e4ca2b011176">The Quick Developers Guide to Migrate Their Apps to Android 11</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Are Kotlin Synthetics Deprecated and What Are the Alternatives?]]></title>
            <link>https://medium.com/better-programming/why-are-kotlin-synthetics-deprecated-and-what-are-the-alternatives-5c2b087dda1c?source=rss-7bb42f1da657------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c2b087dda1c</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Sahil Sharma]]></dc:creator>
            <pubDate>Wed, 16 Dec 2020 17:39:04 GMT</pubDate>
            <atom:updated>2020-12-20T08:10:10.560Z</atom:updated>
            <content:encoded><![CDATA[<h4>Comparing which one to use: data binding vs. view binding vs. Kotlin Synthetics vs. findViewById</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zXX8o8hZLmmS_AHYIff3Wg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@louis993546?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Louis Tsai</a> on <a href="https://unsplash.com/s/photos/kotlin?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Recently Android has announced that with Kotlin 1.4.20, their <a href="https://plugins.gradle.org/plugin/org.jetbrains.kotlin.android.extensions">Android Kotlin Extensions Gradle plugin</a> will be deprecated and will no longer be shipped in the future Kotlin releases.</p><p>Android Kotlin Extensions plugin brought with it two very cool features :</p><ul><li><strong>Synthetics</strong> let you replace calls to findViewById with kotlinx.android.synthetic bindings.</li><li><strong>Parcelize </strong>allows you to remove boilerplate and easily create <a href="https://developer.android.com/reference/android/os/Parcelable">Parcelables</a> through the @Parcelize annotation.</li></ul><p>And with the deprecation of this plugin, we will no longer be able to use these features. Don’t worry about Parcelize, as it will be now shipped as a standalone plugin: kotlin-parcelize. But this is definitely going to be the end for Kotlin Synthetics.</p><p>Now Android developers all across the globe, have, with a very heavy heart, to say goodbye to Kotlin Synthetics. But first, let&#39;s understand why Kotlin Synthetics was introduced in the first place, why it’s deprecated now, and what the options are for us apart from it.</p><blockquote>“Necessity is the mother of invention”</blockquote><h3>History — findViewById</h3><p>Earlier, to get the IDs of views, we were dependent upon findViewById.<br>This method looks very simple, but there were a lot of issues with this that developers were facing.</p><p>This function works by traversing the view hierarchy to find a widget with the ID you specified. It returns the view as soon as it is found or it returns null if it is not present. Let&#39;s discuss some of the issues with this approach:</p><ol><li>By looking at how it works above, we can say that this method is costly. Developers would use it exhaustively at runtime, especially in the earlier implementations of list view’s adapter, and it made their code perform poorly.</li><li>If your view is not present in the layout, you will get NullPointerException at the runtime, i.e., not null safe.</li><li>Prior to Android API 26, it returned the <a href="https://developer.android.com/reference/android/view/View">view</a> (parent class) which you have to manually type cast, and a wrong cast would lead to ClassCastException, i.e., not type safe.</li><li>A lot of boilerplate code. You have to write the same method for all your views, type cast them, and then assign them to a variable.</li></ol><p>Then libraries like <a href="https://jakewharton.github.io/butterknife/">Butter Knife</a> came along to make this approach simpler. Butter Knife improves the issue of boilerplate code partially but still has not solved issues with type safety and null safety. Moreover, it used annotation processing which did slow down the build time a bit. (Note: Butter Knife is now deprecated.)</p><h3>Kotlin Synthetics to the rescue</h3><p>With the <a href="https://plugins.gradle.org/plugin/org.jetbrains.kotlin.android.extensions">Android Kotlin Extensions Gradle plugin</a> released in 2017 came Kotlin Synthetics. For every layout file, Kotlin Synthetics creates an autogenerated class containing your view— as simple as that.<br>You just have to import this plugin in your Gradle file, and you are all set to directly refer to the view reference variables.</p><p>It calls findViewById internally only once and then caches it.</p><p>This was so convenient and such fun to use, so why is it being deprecated</p><p>Let&#39;s analyze it.</p><h4>Pros</h4><ol><li>No boilerplate code — Just configure it once in your Gradle file and you are all set to go. Kotlin Synthetics will automatically generate a class ready for you to use.</li><li>Type safety — All views are picked from your layout file with the type known to it.</li></ol><h4>Cons</h4><ol><li>Partial null safety — It is generally null safe as all your views must be present in the layout file for it to generate. But what if you have multiple layout files based on configurations where some views are present in some layout files and missing in some? Here you have to then manually check for null.</li><li>Pollutes the namespace — You can have the same view ID in different layouts, and you can accidentally import a view of some other layout, which will later at runtime throw NullPointerException.</li><li>Kotlin only — Kotlin Synthetics can only be used with Kotlin. They are not supported with Java. There are still projects that are written in Java and may not be fully migrated to Kotlin yet, and hence Kotlin Synthetics may not be a consistent way of getting the ViewIds in your project.</li></ol><p>Because of these issues, Kotlin Synthetics is now being deprecated.<br>But what to use instead of it? Should we head back to the previous findViewById approach, or are there are some other recommended ways to achieve the same?</p><p>Let&#39;s find out about some recommended approaches.</p><h3>Data Binding</h3><p>As stated in the <a href="https://developer.android.com/topic/libraries/data-binding">documentation</a>, “the Data Binding Library is a support library that allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically.”</p><p>To get started, configure your app to use data binding and enable the dataBinding build option in your build.gradle file in the app module.</p><pre>android {<br>    ...<br>    buildFeatures {<br>        dataBinding true<br>    }<br>}</pre><p>To enable data binding in a layout, you have to manually add the &lt;layout&gt; tag in your layout.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb78c1fa2082e6909cf60d88dfcf6c1a/href">https://medium.com/media/eb78c1fa2082e6909cf60d88dfcf6c1a/href</a></iframe><p>Android Studio will automatically generate classes for your layouts with the Binding suffix. For example, if your layout file name is activity_main.xml, then Android will generate a class called ActivityMainBinding.</p><p>Data binding is very powerful with its support for the following:</p><ul><li>Binding expressions with layouts</li><li>Work with observable data objects</li><li>Binding adapters</li><li>Two-way bindings</li></ul><h4>Pros</h4><ol><li>Null safety — It is null safe. Even if we have multiple layouts based on configurations and few views are present/missing from other configuration layouts, that view would be annotated as @ Nullable.</li><li>Type safety — As all views are picked from your layout file with the type known to it.</li><li><strong>Supports both Kotlin and Java</strong></li></ol><h4>Cons</h4><ol><li>Boilerplate code — Each layout file requires you to manually add the &lt;layout&gt; tag in order for it to support data binding.</li><li>Increased build time — Data binding can increase the build time as it has to generate class files with view and, moreover, with their getter, setter, and evaluating expressions.</li></ol><h3>View Binding</h3><p>Simply, View binding is a very much simpler version/a subset of data binding.<br>The difference between the two is that view binding is only for view references and not for binding UI with data sources.</p><p>To get started, configure your app to use data binding and enable the viewBinding build option in your build.gradle file in the app module.</p><pre>android {<br>    ...<br>    buildFeatures {<br>        viewBinding true<br>    }<br>}</pre><p>For view binding, you do not have to declare anything in your layout file. By default, all layout files will have a generated class file with the Binding suffix ready for you to use.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18873296a1a5bda91537e5caa7b8e2e0/href">https://medium.com/media/18873296a1a5bda91537e5caa7b8e2e0/href</a></iframe><h3>Advantages of View Binding</h3><ul><li>Null safety — Same as data binding</li><li>Type safety — Same as data binding</li><li>No boilerplate code — Unlike in data binding, all layouts are by default eligible for the generation of binding class without any tag.</li><li>No impact on build time — Unlike in data binding, there is no negative impact on the build time.</li><li>Supports both Kotlin and Java.</li></ul><h3>Conclusion</h3><p>View binding and data binding should be the recommended approach.<br>For simpler user cases, use view binding instead of Kotlin Synthetics, and if you are living under a rock and are still using findViewById, then it is high time to migrate.</p><p>If you want to start with data binding and be amazed by its benefits, then it is time to migrate to data binding.</p><p>Alternatively, you can use both view binding and data binding together.<br>All your layout files with the &lt;layout&gt; tag will work with data binding, while other layouts will work with view binding.</p><h3>References</h3><ol><li><a href="https://android-developers.googleblog.com/2020/11/the-future-of-kotlin-android-extensions.html">Android Kotlin Gradle Extension Plugin is deprecated</a></li><li><a href="https://developer.android.com/topic/libraries/view-binding">Learn more about View Binding</a></li><li><a href="https://developer.android.com/topic/libraries/data-binding">Learn more about Data Binding</a></li><li><a href="https://developer.android.com/topic/libraries/view-binding/migration">Migrate from Kotlin Synthetics to View Binding</a></li><li><a href="https://developer.android.com/studio/preview/features/#agp-4-0-0">New Features in Android Studio Preview</a></li></ol><h3>Parting Words</h3><p>Feel free to comment and let me know your suggestions. Do suggest topics that you would like me to cover in my coming articles.</p><p>That’s all! Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c2b087dda1c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/why-are-kotlin-synthetics-deprecated-and-what-are-the-alternatives-5c2b087dda1c">Why Are Kotlin Synthetics Deprecated and What Are the Alternatives?</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Code Stinks! And Here Is Why]]></title>
            <link>https://proandroiddev.com/your-code-stinks-and-here-is-why-ee04b42f6ef3?source=rss-7bb42f1da657------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee04b42f6ef3</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[code-review]]></category>
            <dc:creator><![CDATA[Sahil Sharma]]></dc:creator>
            <pubDate>Tue, 28 Apr 2020 19:43:02 GMT</pubDate>
            <atom:updated>2020-04-29T09:27:58.810Z</atom:updated>
            <content:encoded><![CDATA[<h4>Your code stinks just like an unwashed pair of socks. Let’s identify these stinks and ways to fix them.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cqh7Vax2CvI7bgq8" /><figcaption>Photo by <a href="https://unsplash.com/@jonasleupe?utm_source=medium&amp;utm_medium=referral">Jonas Leupe</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What are Code Stinks or Code Smells?</h3><p>Code stinks are the violation of the fundamentals of good programming that decreases the quality of the code. It means that your code is not clean. Ok, let me explain. Sit Tight!</p><p>From quite some time I have had the opportunity to review codes of my colleagues (Me and my colleagues, we have created a habit to review each others code — the learning phase never ends), of my juniors and even I interact with many people and discuss how to improve code Scalability, Readability, etc.</p><p>I have realized that sometimes people, who may be very good at coding, misses the basic practices.</p><h4>Why should I follow good programming practices? My code compiles anyways!</h4><p>Of course, it does, but think it this way:</p><ol><li>Sooner or later you will have to collaborate with other developers, even with the good developers from all across the world, some may be very senior to you or some may be junior in terms of experience.<br>Writing code with an incorrect naming convention and poor structure will not only create <strong>trouble for the developers to understand your code but also time and efficiency will be affected.</strong></li><li>Change is the only constant. We all face changes every day — whether it is a simple change in the weather, unexpected change of seasons, or A CHANGE OF REQUIREMENT by the client. <br>A simple change in the requirement, if <strong>requiring your whole work to be re-written</strong>, then you should consider reviewing your code.<br>This is a major issue in the Software biz. Failing to cope up with the trend may lead some of your users to migrate to your competition app.</li><li><em>“Your code works, you have no idea why. Your code doesn’t work, you have no idea why”.</em> <br>If your code is very <strong>difficult to read or to debug</strong>, then it is a sign of a Stinky code and it is high time for you to take some action.<br>Failing to properly identify an issue will lead to releasing an unstable build and it may even cause some unwanted behavior of your app and at worse compromise the security and data of your product.</li></ol><p>Being able to identify these stinks and implement cleaner and scalable solutions that save time, money, and effort will help you make a big jump in your programming career.</p><p>So Let’s identify these stinks and see how can we fix or mitigate them…</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F4eoO0NSdNY11K%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F4eoO0NSdNY11K%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F4eoO0NSdNY11K%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="207" frameborder="0" scrolling="no"><a href="https://medium.com/media/729ea06da01244799ee6eca2090e28eb/href">https://medium.com/media/729ea06da01244799ee6eca2090e28eb/href</a></iframe><h3>Improper Naming Conventions</h3><p>Naming conventions are a set of rules for naming identifiers such as Variables, Methods, Classes, Interfaces, and Packages.</p><blockquote>For example: Java uses Camel Case. Where Classes and Interfaces starts with a Capital Letters, functions and variables starts with small letter.</blockquote><p>Using incorrect naming conventions or mixing different types of conventions together in a single codebase is the worst mistake you can ever make.<br>Not only will it make you look an under-experienced programmer but will also make your code difficult to read and maintain.</p><h4>Solution</h4><p>Naming convention is the first thing a person learns in his programming course. Using incorrect naming conventions not only affects the code but it makes a bad impression on the programmer as this is the basic thing that is expected from a professional programmer.</p><p>Read about a Programming Language’s naming conventions. You can easily find it on its official website or anywhere from where you are learning.</p><h3>Tight Coupling</h3><p>Tight coupling is when two objects are so dependent on one another’s data and/or functions that modifying one requires modifying the other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*KEBd3ImiZppJMfvEdQNGzQ.png" /><figcaption>Tightly Coupled Code</figcaption></figure><h4>Solution</h4><p>Opposite of Tight Coupling is Loose Coupling. While Tight Coupling means that your code is so tightly coupled that modifying a single class is not possible without major changes in the paired couplet, Loose Coupling, on the other hand, means that you can modify your class with or without minor changes required in the other class.</p><blockquote>The key point for loosening the coupling is Abstraction.</blockquote><p>If the actual implementation is abstracted, ie. Class A does not know the working of Class B but only communicates by the shared contract, which is defined using an ‘interface’ in the example as illustrated below.</p><p>In our case, the Employee is dependent on the Bike to commute to his work.<br>Now if the Employee is asked to drive a Car. How will he? <br><em>Here, Employee knows about the Bike hence there is no abstraction.</em></p><p>Let’s now create a Vehicle <strong>interface</strong> and derive all our vehicles from it.</p><p>As in the illustration below, now we are providing only the Vehicle implementation to the Employee. Hence Employee only knows that he can drive a Vehicle — which Vehicle? He is not concerned.<br>Now Bike can be easily changed to Car, and everything else remains the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*wFtMM3Z3wjBt0azeaXyWQw.png" /><figcaption>Loosely coupled code</figcaption></figure><p><strong>Let me give you a Real-Life example: <br></strong>Suppose you are working on a Food and Restaurant application like Zomato. In this application, you have created a module Restaurant Finder. And another team is working on a module for Food Catalog. You are asked by your Team Manager to extract the search module and make it a commonly shared module that everyone can plug and use.<br>When you try to extract the classes of your module, you realize that your classes also depend on several other classes. And you end up extracting half of your module. That is Tight Coupling!</p><h3>God Classes</h3><p>A God class is simply a huge class that contains too much code. We call them God Classes because these classes are doing too much. :)<br>It causes Tight Coupling &amp; cramped code and affects the readability and maintainability of the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*4RpNOyko7rPhZOj91SwqEg.png" /><figcaption>Don’t</figcaption></figure><h4>Solution</h4><p>You could break it into compositions. ie. Breaking a Big class into several classes based on their responsibilities. aka Single Responsibility Principle.</p><p><strong>Single Responsibility Principle</strong> states that every module or class should have <strong>responsibility</strong> over a <strong>single</strong> part of the functionality provided by the software and that responsibility should be entirely encapsulated by the class, module, or function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*HzGa357PB-Qy1SEqceSn0w.png" /><figcaption>Do</figcaption></figure><p><em>Just like God Classes, similar analogy applies to God Functions and God Parameter list in a function. The concept is the same.</em></p><p><strong>Real-Life Example:<br></strong>Back in the days, When I first started with segregation of code — I divided my Views, my Presenters, and the Data layer quite nicely. I introduced a DataManager class which would provide will all the data that is needed by the presenter. The Presenter just needs to inject (call) it. <br>Sounds neat, but what actually happened was that this DataManager class, being responsible for all the data needs, became very huge.<br>And over time it got very difficult to manage. For a clean code, this is something to be avoided. Later I broke this down into functionality specific managers or repositories — like UserRepository, WorkerRepository.</p><h3>Middle Man</h3><p>A middle man is a class that exists solely to refer other classes. <br>ie. A class that does not have any independent and significant function but just acts as a mediator.</p><h4>Solution</h4><p>If a sole purpose of a class is just to link data from another class and else have no other role, it needs to be reviewed and if it is the only purpose of this class then it is better to remove it.</p><p>Unnecessary classes like these are just increasing the overhead and not contributing towards a clean code.</p><h3>Hardcoded Values</h3><p>Hardcoded Values ie. Constant literals that are mentioned in your code, but you cannot just make sense of what they actually mean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*9uyS7ETGDbotnPq-XSPJJA.png" /><figcaption>Cannot make sense of these numbers</figcaption></figure><h4>Solution</h4><p>Some programmers may conveniently leave a comment on the value explaining what does it mean. This approach is not recommended as wherever and whenever you are writing or updating the constants you have to keep track of where all it has been used. It is highly error-prone and not a feasible approach.</p><p>The better approach is to convert the Hardcoded values into constant variables or enumerations. This way the code will make sense to someone who is reading it, and any future changes in the constant value — you will be sure that the same is reflected elsewhere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*jnpwB8Z0QYC-weDHJKKxMA.png" /><figcaption>Do</figcaption></figure><h3>Unhandled Exceptions</h3><p>Exception handling is a very powerful concept but nowadays programmers have started to misuse it. Many lazy programmers try to wrap every possible piece of code that crashes with a try-catch block and sometimes even ignore the caught exception.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*1wlsvVYgmF3DJ6KamrPnBw.png" /><figcaption>Don’t</figcaption></figure><p>In the above example, there could be multiple reasons an exception would be thrown. Here the exceptions are not handled individually so if something goes wrong, the user will not have a clue of what specifically is wrong.<br>Also, the chances are that the developer himself would not be able to debug the issue easily as the exception was ignored. This is an example of a very bad coding practice.</p><h4>Solution</h4><p>Firstly, try to catch specific exceptions first followed by a general exception.<br>This way you would be able to better respond on the basis of the type of exception thrown.</p><p>Secondly, never ignore a caught exception until absolutely necessary.<br>If you think there is not much handling required, then at least try to <strong>log</strong> it so that if something goes wrong it can be detected while debugging.<br>Even a simple bug left undetected can lead to a bigger problem in the future and ignoring the exceptions is guaranteed to cause hours of your precious time wasted debugging later.</p><p><strong>Real-Life Example:<br></strong>A friend of mine once encountered a crash in his application. He tried to reproduce it but was not able to. Hence he just wrapped the whole code inside try-catch block and did not even debug print the exception.<br>For quite some time it seemed that the problem was solved, until one day the QA Team guy caught an unusual behavior in the app.<br>There was a problem in parsing a certain value from the API. And hence was not reproducible for every user. He and everyone else were not able to detect the problem as the exception was never thrown/ printed. And the UI showed a cute message that the data is not available at this time.<br>Now just think about the live-app users.</p><h3>Not Annotating Parameters</h3><p>Not properly annotating the parameters and variables — such as not specifying its a value can be null or not, can be optional or not, not providing a proper default value (if overridden), can make your code error-prone.</p><h4>Solution</h4><p>Parameters should be properly annotated, especially when defining a Data Model. Along with their types their nullability, default value (if overridden), etc should be mentioned. Doing this there will be fewer chances of errors in your code as everything will be strictly defined.</p><p>A simple use case would be deserializing a JSON response from a Network API to a Data Model. You cannot count on data from another source. If any parameter is missing, Nulls or default values should be handled at your end to avoid unexpected results or even crashes.</p><h3>Duplicate Code</h3><p>When the same set of lines are to be used in multiple areas of your code.<br>For example, you have to beautify an input string and print it on the console. You copied the same set of code where ever you needed it.<br>Later, you realize you need to modify that logic, but don’t remember all the places where you implemented it.<br>You end up missing a few places, resulting in buggy and inconsistent behavior.</p><h4>Solution</h4><p>Duplicate code is a prime candidate for being turned into a function.<br>It is better to call the same function where ever you require that code.<br>This will allow you to modify the function once and the same is reflected elsewhere, hence no ambiguities, no wasting of time in writing the same line multiple places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*km_j7IBaDWb7tLpFnj-YAA.png" /><figcaption>Do — Instead of writing the same line in multiple places- we have converted it into a function</figcaption></figure><h3>Lack of Comments</h3><p>There is a fine line between Lack of commenting and Unnecessary commenting ie. Overkill.</p><p>The code has absolutely no comments anywhere ie. No documentation blocks, no usage overviews for classes, no explanation where required, OR<br>it is full of comments, even for silly things, which makes the code ugly and unreadable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*Dy2z5jpUsT9-2Nig3qG8Wg.png" /><figcaption>Lol.</figcaption></figure><h4>Solution</h4><p>“A Good code is self-documenting” — True, But does that mean that we should never comment? No!</p><p>The goal of an easy-to-maintain codebase should be code that’s written well enough that it doesn’t <em>need</em> comments, but still has them. And when writing comments, aim for comments that explain <em>why</em> a snippet of code exists instead of explaining <em>what</em> it’s doing.</p><p>Comments are basically of two types:</p><ul><li><strong>Documentation Comments<br></strong>These comments are intended for someone who is going to consume your code but never read it. If you are building some Framework or a Library you also need to provide API documentation. But as soon as you make a change in your code, you also need to update the documentation. But that is quite the effort so the solution is to embed the documentation directly into the code and extract it using some documentation tools like JavaDoc.</li><li><strong>Clarification Comments<br></strong>These comments are for someone who may read your code and this is where the code can stink. Your code should be self-explanatory.<br>Overdoing clarification comments or commenting unnecessarily is a bad coding practice.</li></ul><p>Practically I think that we all be in a situation where we have to write code in a certain way due to, maybe, urgent release or some unavoidable constraints where it becomes mandatory to use clarification comment. It is good to use clarification comment then as else you or others won’t be able to guess why this code is here, but then such situations should be very rare.</p><blockquote><strong>“ Comments are good for the soul and sanity. “</strong></blockquote><h3>Deep Nesting</h3><p>There are two main ways to end up with deeply nested code: loops and conditional statements. Deeply nested code isn’t always bad (<em>eg. Traversing a matrix)</em>, but can be difficult both for its purpose (the name should express what it do) and for its maintainer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*eX0nEMepLvxW5ScPgWmcAg.png" /><figcaption>Deep Nesting — Don’t</figcaption></figure><h4>Solution</h4><p>If you find yourself writing a code drowned deep into the layers of loops or conditions, first review your code that if your algorithm is correct and optimized. If you think it is, figure out that is there any piece of code that can be converted into a function.<br>Deep Nesting ofter leads to Long Function, hence try to break it into compositions.</p><p>If your code has very deep nesting of conditional loops, try considering <a href="https://en.wikipedia.org/wiki/Strategy_pattern">Strategy Pattern</a>.</p><blockquote><strong>“ deeply-nested conditional statements are often a sign that you’re trying to handle too much logic in a single function or class.<br>In fact, deep nesting and long functions tend to go hand in hand. “</strong></blockquote><h3>Over-Optimized Code</h3><p>When a code that is excessively optimized for performance when the application doesn’t have a large user base or algorithms that are optimized to the max when real-time performance isn’t really needed.</p><h4>Solution</h4><p>Over-Optimizing your code needlessly will only increase complexity, efforts, impact deadlines, and hurt maintainability.<br>It should be avoided. If your code is good enough and scalable you can always scale up things in the future, if the requirement demands.</p><h4>Example</h4><p>Think it this way, you are asked to make a system for a company to be used internally by a maximum of 100 users. And you are asked strictly to deliver it within a month.<br>But you being an over-smart programmer decides to make a system that can support a million users (That limit would practically never reach given the use-case).<br>After the month completes, you are not yet ready with your project. You were trying to target a million users but at the time of delivery, you are not even in a position to cater a hundred. And now you need 2 more months just to make something that was not required.<br>That is a sheer waste of time, resources, and money.</p><h3>Mind the Scope</h3><p>One of the major examples of bad programming practice and cause for bugs is the non-consideration of the scope of the data variable.<br>ie. Maintaining and observing data in different scopes and syncing between them.</p><p>Let’s take the example of a mobile application. A UI Container (Page) that you see on the screen is bound to a lifecycle (Visible state, Background State) and is the foreground part that the user interacts with. <br>Suppose the app fires a Rest API to fetch the data from the cloud and display it on the UI Container.<br>In the meantime, the user switches to another app. Now if the API returns the result, any operation required on the view (which is now destroyed) will cause the app to crash.</p><blockquote>Do note that here the background service has the scope of the application.<br>And the View has the scope of a the UI Container which is bounded by a Lifecycle. So a View can be in a destroyed state or in-active state and the service will keep running in the background.</blockquote><p>Another point to consider will be that if the same view, in its foreground states, calls another background service such that the background service has the reference of the foreground service.<br>In the meanwhile if the user moves the app to the background, will the foreground view will be killed? No — Because it is not eligible for <a href="http://net-informations.com/java/cjava/eligible.htm">Garbage Collection</a>. And this will cause a Memory Leak.</p><h4>Memory Leaks</h4><p>A memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in such a way that memory which is no longer needed is not released.</p><p>These leaks are Caused by Ever Lasting objects, Circular Dependencies, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*C_WH56Hz0TAB-b2Zs2lXFA.jpeg" /></figure><h4>Solution</h4><p>Firstly maintaining and observing data from two different scopes is highly discouraged. Always try to observe a <a href="https://en.wikipedia.org/wiki/Single_source_of_truth">Single source of Truth</a>.<br>If you are creating threads such that one thread is referring another thread, like in our example above Background thread was referring the Main thread, the handling of both the thread should be taken care of.<br>Make sure the resources are released properly, especially in the case of Threading.</p><p>Few strategies what helps to avoid memory leaks:<br>✓ Avoid using inner classes to perform a task in a different thread, as inner classes hold the reference of their outer classes implicitly. And if you have to do it make sure that their lifecycles are managed.<br>✓ Use weak references in such cases<br>✓ Avoid static variables for storing data.<br>✓ Make sure you handle the app lifecycle properly.</p><h3>TL;DR</h3><p>I have described the importance of a Clean Code — removing all that stink.</p><ul><li><strong>Improper Naming Conventions</strong>: Follow proper naming conventions</li><li><strong>Tight Coupling</strong>: Try to loosen the code. Add a layer of Abstraction.</li><li><strong>God Classes</strong>: Try to break it into compositions.</li><li><strong>Middle Man</strong>: Unnecessary, so avoid.</li><li><strong>Hardcoded Values</strong>: Causes ambiguity. Use Constant Variables instead.</li><li><strong>Unhandled Exceptions</strong>: Don’t abuse; Try to catch specific exceptions; Never ignore caught exceptions, at least log it.</li><li><strong>Not Annotating Parameters</strong>: May cause runtime crashes, hence annotate parameters and variables properly.</li><li><strong>Duplicate Code</strong>: Convert the code that has to be re-used into a function.</li><li><strong>Lack of Comments</strong>: For API Documentation commenting is a must; Clarification Comments only where it is absolutely necessary.</li><li><strong>Deep Nesting</strong>: Try to break it into compositions; Try considering <a href="https://en.wikipedia.org/wiki/Strategy_pattern">Strategy Pattern</a>.</li><li><strong>Over-optimized Code</strong>: Don’t waste time overly complicating your code. If it is good enough and in future is requirement demands, you can always scale it up.</li><li><strong>Mind the scope</strong>: Make sure of <a href="https://en.wikipedia.org/wiki/Single_source_of_truth">Single source of Truth</a>; Make sure resources are cleared when not required anymore.</li></ul><blockquote>“Any fool can write code that a computer can understand, good programmers write code that every human can understand.” — Martin Fowler</blockquote><h3>Read More</h3><ul><li>You can read more about writing a Clean Code, compare and try numerous solutions available in the market best for your use-case. <br>Eg. <a href="https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html">Clean Architecture by Robert C. Martin</a>, etc.</li><li>You can read more about <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">OOPs</a> concepts, like its Design Principles like <a href="https://en.wikipedia.org/wiki/SOLID">SOLID Principle</a>s.</li><li>You can read more about the different <a href="https://en.wikipedia.org/wiki/Software_design_pattern#Creational_patterns">Software Design Patterns</a>.</li></ul><h3>Closing Thoughts</h3><p>And we are at the end of this article.</p><p>I have tried to cover all the points to give you a head start. The said points, according to me are most important for removing all that stink from your code and head towards cleaner code.<br><strong>Just remember that the difference between an average programmer and a good programmer is the ability to write cleaner, scalable, and efficient code.</strong><br>I hope that these practices or tips will be enough to help you get started with writing clean code.</p><p>A new day, start coding a new way — a cleaner way.</p><p>That’s All!<br>Thank You</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee04b42f6ef3" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/your-code-stinks-and-here-is-why-ee04b42f6ef3">Your Code Stinks! And Here Is Why</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boost Your Kotlin Productivity With Extensions and Higher-Order Functions]]></title>
            <link>https://medium.com/better-programming/boost-your-kotlin-productivity-with-extensions-and-higher-order-functions-a19ebaf2aeac?source=rss-7bb42f1da657------2</link>
            <guid isPermaLink="false">https://medium.com/p/a19ebaf2aeac</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Sahil Sharma]]></dc:creator>
            <pubDate>Mon, 27 Apr 2020 18:24:07 GMT</pubDate>
            <atom:updated>2020-04-27T19:08:17.047Z</atom:updated>
            <content:encoded><![CDATA[<h4>Make your code cleaner and more manageable</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vsRne2fVulXqWnRK0EZgEQ.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@luis-gomes-166706?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">luis gomes</a> from <a href="https://www.pexels.com/photo/blur-close-up-code-computer-546819/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a>.</figcaption></figure><p>At Google I/O 2017, Google announced that the programming language <a href="https://kotlinlang.org/">Kotlin</a> was now officially supported for Android app development. Since then, there has been no looking back. As of Google I/O 2019, Android mobile development has been Kotlin-first.</p><p>Instead of raving about all its features like null safety, data classes, filtering, or interpretability with Java, I am going to describe the two features of Kotlin that I cannot live without. They are guaranteed to save you hours.</p><h3>Extensions</h3><p>Kotlin provides the ability to extend a class with new functionality without having to inherit from the class or use design patterns such as a decorator. <br>This is done via special declarations called extensions. You can create extensions of functions, class members, etc.</p><p>In simple terms, this is how an extension function works: Without extending a class, you are defining a function into it and now you can use it throughout.</p><p>To define an extension function, all you have to do is define a function with a name such as &lt;ClassNameYouWishToInherit&gt;.&lt;YouMethodName&gt;.</p><pre><br>fun MutableList&lt;Int&gt;.swap(index1: Int, index2: Int) {<br> val tmp = this[index1] // ‘this’ corresponds to the list<br> this[index1] = this[index2]<br> this[index2] = tmp<br>}</pre><h3>How to Boost Productivity With Them</h3><p>Let&#39;s start with a very simple use case. In Android development, there is some common code that you find yourself using very often (e.g. showing a toast, a simple alert dialog, etc.). And for that, you have to write this same clingy line of code every time:</p><pre>Toast.makeText(this.<em>applicationContext</em>, txt, Toast.<em>LENGTH_SHORT</em>).show()</pre><h4>Magic of extension functions</h4><p>Let’s create an extension function for showing a toast message:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6639fdfc5099c0cfc82abc9f6346ba32/href">https://medium.com/media/6639fdfc5099c0cfc82abc9f6346ba32/href</a></iframe><p>In the snippet above, we created the extension function toast for the Activity class. Now all you have to do is call toast in the Activity class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/108ac7b68a10a45b0907de632f6a5dae/href">https://medium.com/media/108ac7b68a10a45b0907de632f6a5dae/href</a></iframe><p>Similarly, we can create extension functions, say, for LayoutInflator:</p><pre>fun View?.layoutInflator() = LayoutInflater.from(this?.<em>context</em>)<br><br>fun ViewGroup?.layoutInflator() = LayoutInflater.from(this?.<em>context</em>)<br><br>fun Fragment?.layoutInflator() = LayoutInflater.from(activity?.context)</pre><p>In the snippet above, we created an extension for View, ViewGroup, and even the Fragment class.</p><h4>More complex use case</h4><p>Now let’s get to the actual use case. The other day, I found myself working on <a href="https://www.mapbox.com/">Mapbox SDK</a>. The code was something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b668ca275b0f0116e4321f772264118/href">https://medium.com/media/4b668ca275b0f0116e4321f772264118/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2697294e062266147c3704133fb97fd/href">https://medium.com/media/d2697294e062266147c3704133fb97fd/href</a></iframe><p>Extension functions to the rescue:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9ee279f730efa3ece6c43e29d4a4d3e/href">https://medium.com/media/e9ee279f730efa3ece6c43e29d4a4d3e/href</a></iframe><p>In the code snippet above, we created an extension function of MapView directly. All the code of getting the callbacks and then adding the layer is done by simply calling MapView’s addLayer extension function.</p><p>The addLayer function will now be treated as the MapView class’s own function.</p><p>Another way of doing this would be to extend the MapView class and add those functions. But why go through so much pain and refactor your existing code when you can just add an extension function?</p><p>We will optimize this even further.</p><h3>Higher-Order Functions</h3><p>A higher-order function is a function that takes functions as parameters or returns a function.</p><blockquote>“Kotlin functions are <a href="https://en.wikipedia.org/wiki/First-class_function"><em>first-class</em></a>, which means that they can be stored in variables and data structures, passed as arguments to and returned from other <a href="https://kotlinlang.org/docs/reference/lambdas.html#higher-order-functions">higher-order functions</a>. You can operate with functions in any way that is possible for other non-function values.” — <a href="https://kotlinlang.org/docs/reference/lambdas.html">Official documentation</a></blockquote><p>Example:</p><pre>fun sayHello(funcAsArg: (String) -&gt; Unit) {<br> funcAsArg(“Hello”)<br>}</pre><p>In the snippet above, we created the sayHello function that accepts another function as an argument. And this function accepts String as a parameter and returns Unit (similar to void in Java).</p><p>With the help of these functions as arguments, we can get rid of defining interfaces for such simple use cases (i.e. interfaces with just a single method used to just callbacks).</p><p>We can further optimize the code by removing interfaces, as they are difficult to maintain and have no use here other than to be used for callbacks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ea4794497fd7785c5e060a5532a8836/href">https://medium.com/media/6ea4794497fd7785c5e060a5532a8836/href</a></iframe><h3>Final Code</h3><p>Finally, our Mapbox extension Kotlin file looks something like this (below).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46e863f8476b9eb5264017cb0078f5c2/href">https://medium.com/media/46e863f8476b9eb5264017cb0078f5c2/href</a></iframe><p>We have created several extension functions (for getting the Map instance, Style instance, to add Layer, etc.).</p><p>With all the stuff handled by the Extension functions and HoFs, our code becomes much more compact and readable.</p><h4>Code comparison</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wRyoVJyzaShI7G43xReBbQ.png" /><figcaption>Before = 53 lines | After = 17 lines</figcaption></figure><p>The <em>after</em> (right side) looks compact, readable, and at the same time saves us from writing duplicate code again and again.</p><h3>References</h3><ul><li>Extensions: <a href="https://kotlinlang.org/docs/reference/extensions.html">https://kotlinlang.org/docs/reference/extensions.html</a></li><li>Higher-order functions: <a href="https://kotlinlang.org/docs/reference/lambdas.html#higher-order-functions">https://kotlinlang.org/docs/reference/lambdas.html#higher-order-functions</a></li></ul><h3>Closing Note</h3><p>There is so much you can achieve with just these two features. The sky is the limit. Try them out and comment on how they made your life easier. Also, feel free to comment about your experience with Kotlin and how you get the most out of it.</p><p>That&#39;s all! I hope you liked this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a19ebaf2aeac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/boost-your-kotlin-productivity-with-extensions-and-higher-order-functions-a19ebaf2aeac">Boost Your Kotlin Productivity With Extensions and Higher-Order Functions</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Essential Android Studio Plugins Every Android Developer Must Have]]></title>
            <link>https://medium.com/better-programming/5-essential-android-studio-plugins-every-android-developer-must-have-6669dd09f0a1?source=rss-7bb42f1da657------2</link>
            <guid isPermaLink="false">https://medium.com/p/6669dd09f0a1</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Sahil Sharma]]></dc:creator>
            <pubDate>Mon, 20 Apr 2020 00:12:55 GMT</pubDate>
            <atom:updated>2020-04-20T00:12:55.469Z</atom:updated>
            <content:encoded><![CDATA[<h4>ADB Idea, .ignore, and more</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KGKiu-kpwKJ8Hntk" /><figcaption>Photo by <a href="https://unsplash.com/@austinpoon?utm_source=medium&amp;utm_medium=referral">Austin Poon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you’re working from home, I hope that you’re trying your best to be productive. Being productive is not only about coding, but <em>smart</em> coding.</p><p>Android Studio is the power-packed official Android IDE based on <a href="https://www.jetbrains.com/idea/">IntelliJ IDEA</a> and comes with an endless list of plugins which, if used right, can make your work more efficient and faster.</p><p>Here is a list of a few Android Studio plugins that, according to me, are the basic essential plugins that every developer must have to boost their productivity and save hundreds of hours.</p><h3>1. ADB Idea</h3><p>As an Android developer, you must have been in a situation where you have to frequently delete the app data, revoke all permissions, or kill an app to test whether your app can handle process death or not.</p><p>Doing these tasks requires some steps; you have to find your app &gt; go to the app settings &gt; storage &gt; clear data.</p><p>All this is simplified by the <a href="https://plugins.jetbrains.com/plugin/7380-adb-idea">ADB Idea plugin</a>.</p><p>It provides single-click shortcut commands for all these operations (kill an app, uninstall, clear data, revoke permissions). ADB Idea makes life really simple and it is a must-have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*SLkB9Bkh1W0yce4dqLUSwg.png" /></figure><h3>2. ADB WiFi</h3><p>We all are shifting towards wireless alternatives, aren’t we? These days, we have wireless speakers, wireless headphones, and even wireless charging. So, why you are still using a wire to debug your application?</p><p>Here comes the <a href="https://android.jlelse.eu/wireless-debugging-through-adb-in-android-using-wifi-965f7edd163a">ADB WiFi</a> plugin. All you need to do is make sure your host machine and your phone are connected to the same network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*UWPX3VPS1WJcSAgKTcSjKg.png" /></figure><p>Many times, I have been in a situation where I do not have a cable handy and need to debug something urgently, thanks to ADB WiFi.</p><h3>3. .ignore</h3><p>Most of the newbie developers, while developing their first application, after integrating a version control system (VCS), Git, push all the files to the repository. (In fact, some of the intermediates may still be doing it, too…)</p><p>These project files also include some editor configuration files, which, if you push them, will lead to a conflict in merging every time you try to merge your code. E.g. vcs.xml, workspace.xml.</p><p>This is because these settings will be different on different IDEs and according to the developer’s preference. Hence, these files must be ignored.</p><p><a href="https://plugins.jetbrains.com/plugin/7495--ignore">.ignore</a> is a plugin that helps you to easily manage the ignore files. Like <a href="https://www.atlassian.com/git/tutorials/saving-changes/gitignore">.gitignore</a> (Git), <a href="http://npm.github.io/publishing-pkgs-docs/publishing/the-npmignore-file.html">.npmignore</a> (npm), <a href="https://docs.docker.com/engine/reference/builder/">.dockerignore</a> (Docker), etc.</p><p>It lets you create an ignore file and generates ignore rules according to the respective templates and, hence, takes all the overhead away from you. It also helps to highlight ignored files in the IDE and lets you easily add new files or edit the existing rule.</p><h3>4. JSON to Kotlin Class Generator</h3><p>Ever had to deal with long JSON responses from APIs and had a hard time manually making data models for them?</p><p>Well, <a href="https://plugins.jetbrains.com/plugin/9960-json-to-kotlin-class-jsontokotlinclass-">JSON to Kotlin Class generator</a> is a simple plugin that generates a Kotlin class from any legal JSON string/JSONSchema or any URLs that return a JSON string/JSONSchema as response.</p><p>It is very useful as it saves time from dealing with large and complex JSON.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*79buJU6GxM3ldghEDrY0dw.png" /></figure><p>There are many websites as well that do the same thing, but having a plugin handy is great.</p><h3><strong>5. CodeGlance</strong></h3><p>If you have come from a web or iOS background, or if you have used the <a href="https://www.sublimetext.com/">Sublime editor</a>, you must be familiar with this plugin.</p><p><a href="https://plugins.jetbrains.com/plugin/7275-codeglance">CodeGlance</a> previews the file’s code, like an eagle view, and lets you quickly navigate to the desired section. It is pretty cool and often saves the pain of finding/navigating your code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*3Ln2a9pRu5ARm7fdz_n-aA.png" /></figure><h3>Bonus</h3><p>OK! So, here is a surprise, I am including a bonus plugin for you all.</p><p>I did not include it in the main points above as you may alternatively use Android Studio’s Asset Generator, but I find this tool very useful and always found myself cheating on Android Studio’s Asset Generator with it. Hence, I thought it is worth mentioning.</p><h4><strong>6. Material Icon Generator</strong></h4><p>The designing part, making beautiful UIs, is fun. It is a very important aspect of an Android application as it is the first thing a user notices. And, good UI and UX will lead to happy user experience and will leave a good impression of an app.</p><p>While working with the UI, you may often find the need to use some icons. And for <a href="https://google.github.io/material-design-icons/">Google’s Material icons</a>, you may either visit Google’s Material website or use the Android Studio default Asset Generator.</p><p>But you will still face a set back as, on the Material website, you do not have the option to customize your asset. That’s where the <a href="https://plugins.jetbrains.com/plugin/7647-android-material-design-icon-generator">Material Icon Generator</a> comes into play.</p><p>Just select your icon, choose between vector or PNG, select a size or use default, select a color or use the default. And you are ready to go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u4XnzbiCXXAMAxP-GS9moA.png" /><figcaption>Back in the days, this plugin was most useful as Android Studio’s Asset Generator wasn’t that cool.</figcaption></figure><h3>Closing Notes</h3><p>I have not mentioned plugins that customize themes; been there, done that, back to the original “Darcula” theme.</p><p>Anyway, I hope you like it and will try to incorporate these plugins in your day-to-day work. See which ones work for you the best and decide accordingly.</p><p>Just don’t overwhelm your Android Studio with a ton of plugins as it may impact the performance negatively.</p><p>So, whilst at home and being able to save time with these plugins, what are you going to do?</p><p>I am going to watch Money Heist season four now.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6669dd09f0a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/5-essential-android-studio-plugins-every-android-developer-must-have-6669dd09f0a1">5 Essential Android Studio Plugins Every Android Developer Must Have</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>