<?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 Priya Shekhat on Medium]]></title>
        <description><![CDATA[Stories by Priya Shekhat on Medium]]></description>
        <link>https://medium.com/@shekhatpriya16?source=rss-2034cf90f040------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oORKKF81bEwRN_eOEgLbZg.jpeg</url>
            <title>Stories by Priya Shekhat on Medium</title>
            <link>https://medium.com/@shekhatpriya16?source=rss-2034cf90f040------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 08:57:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shekhatpriya16/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[Introduction to Android WorkManager]]></title>
            <link>https://medium.com/@shekhatpriya16/introduction-to-android-workmanager-6bb6bd72965f?source=rss-2034cf90f040------2</link>
            <guid isPermaLink="false">https://medium.com/p/6bb6bd72965f</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[workmanager]]></category>
            <category><![CDATA[mobile-development]]></category>
            <dc:creator><![CDATA[Priya Shekhat]]></dc:creator>
            <pubDate>Thu, 05 Mar 2020 11:18:40 GMT</pubDate>
            <atom:updated>2020-03-05T11:18:40.326Z</atom:updated>
            <content:encoded><![CDATA[<p>We have lot of considerations for handling background work in which one of the Android Jetpack library called as <a href="https://developer.android.com/topic/libraries/architecture/workmanager/">WorkManager</a>, which expands on the capabilities of the <a href="https://developer.android.com/reference/android/app/job/JobScheduler">JobScheduler</a> framework . WorkManager beta was already released!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*flIZ4WoJ1tj3Gsb04OKVZQ.png" /></figure><h4>What is WorkManager?</h4><p>WorkManager is basically a task scheduler, It makes it easy to specify the asynchronous task and when they should run. The Work Manager API helps create the task and hand it to the Work Manager to run immediately or at an appropriate time as mentioned. For example, you might point your app to download new resources from the network from time to time and now the <strong>downloading</strong> is a task and you can set up this task to run at an appropriate time depending on the availability of the WIFI network or when the device is charging. So this way you can schedule a task using WorkManager.</p><h4><strong>Why WorkManager?</strong></h4><p>The Android dev team is continuously working on battery optimizations. After that team introduced <em>Doze mode.</em> Then in Oreo imposed various kind of <a href="https://androidwave.com/background-limitations-android-oreo/">limitation on performing background jobs. </a>Before WorkManager, we use various job scheduler for performing background task, such as Firebase JobDispatcher, Job Scheduler and Alarm Manager + Broadcast receivers. So for the developer perspective, it is difficult to choose which scheduler should use and which one is good. So the Work Manager handles these kinds of stuff. We have to pass the task to the WorkManager and It uses all this Firebase Job Dispatcher, Alarm Manager + Broadcast Receivers, Job Scheduler to perform the background task depending on the requirement.</p><h4>How to use WorkManager?</h4><p>Add the WorkManager dependency in Java or Kotlin to your Android project following the instructions in the <a href="https://developer.android.com/jetpack/androidx/releases/work#declaring_dependencies">WorkManager release notes</a>.</p><p>A task is defined using the <a href="https://developer.android.com/reference/androidx/work/Worker">Worker</a> class. The doWork() method is run synchronously on a background thread provided by WorkManager.</p><p>To create your background task, extend the Worker class and override the doWork() method. For example, to create a Worker that uploads images, you can do the following:</p><pre>class UploadWorker(appContext: Context, workerParams: WorkerParameters)<br>    : Worker(appContext, workerParams) {<br><br>    override fun doWork(): Result {<br>        // Do the work here--in this case, upload the images.<br><br>        uploadImages()<br><br>        // Indicate whether the task finished successfully with the Result<br>        return Result.success()<br>    }<br>}</pre><p>The <a href="https://developer.android.com/reference/androidx/work/ListenableWorker.Result">Result</a> returned from doWork() informs WorkManager whether the task:</p><ul><li>finished successfully via Result.success()</li><li>failed via Result.failure()</li><li>needs to be retried at a later time via Result.retry()</li></ul><p>While a Worker defines the unit of work, a <a href="https://developer.android.com/reference/androidx/work/WorkRequest">WorkRequest</a> defines how and when work should be run. Tasks may be one-off or periodic. For one-off WorkRequests, use <a href="https://developer.android.com/reference/androidx/work/OneTimeWorkRequest">OneTimeWorkRequest</a> and for periodic work <a href="https://developer.android.com/reference/androidx/work/PeriodicWorkRequest">PeriodicWorkRequest</a>. For more information on scheduling recurring work, read the <a href="https://developer.android.com/topic/libraries/architecture/workmanager/how-to/recurring-work">recurring work documentation</a>.</p><p>n this case, the simplest example for building a WorkRequest for our UploadWorker is:</p><pre>val uploadWorkRequest = OneTimeWorkRequestBuilder&lt;UploadWorker&gt;()<br>        .build()</pre><p>The WorkRequest can also include additional information, such as the constraints under which the task should run, input to the work, a delay, and backoff policy for retrying work. These options are explained in greater detail in the <a href="https://developer.android.com/topic/libraries/architecture/workmanager/how-to/define-work">Defining Work guide</a>.Once you have defined your WorkRequest, you can now schedule it with <a href="https://developer.android.com/reference/androidx/work/WorkManager">WorkManager</a> using the <a href="https://developer.android.com/reference/androidx/work/WorkManager.html#enqueue(androidx.work.WorkRequest)">enqueue()</a> method.</p><pre>WorkManager.getInstance(myContext).enqueue(uploadWorkRequest)</pre><p>The exact time that the worker is going to be executed depends on the constraints that are used in your WorkRequest and on system optimizations. WorkManager is designed to give the best possible behavior under these restrictions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6bb6bd72965f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best plugins for android studio to make application development Superfast!]]></title>
            <link>https://medium.com/@shekhatpriya16/best-plugins-for-android-studio-to-make-application-development-superfast-e57dd6c61bfa?source=rss-2034cf90f040------2</link>
            <guid isPermaLink="false">https://medium.com/p/e57dd6c61bfa</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Priya Shekhat]]></dc:creator>
            <pubDate>Wed, 04 Dec 2019 06:12:08 GMT</pubDate>
            <atom:updated>2019-12-04T06:12:08.699Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*jt5G7_M0CB2rS-v8u4fi-w.png" /><figcaption>Wow…!!!!!!</figcaption></figure><p>Become an Android developer, you always love the Plugins to use to make the android development easier and faster. Android Studio provides the awesome feature for android developer to connect with your favourite plugins. So in this tutorial, we will learn some of the best plugins that need to install to every android developer to develop the android apps super fast. These plugins are simply awesome for daily uses to make awesome Android apps.</p><p>Let’s get started with the few list of plugins to install in your android studio.</p><ol><li><strong>ADB WIFI</strong></li></ol><p>It is an Android Studio plugin for <a href="https://developer.android.com/studio/command-line/adb.html"><em>debugging</em></a> your Android app over Wi-Fi. This plugin is pretty good to connect your device to wifi. Once you installed this plugin then You do not require to connect your device to USB cable. I was really frustrated to connect with USB cable because my device USB port is very loose and while running debug the app it got the disconnect almost time. Installation of each plugin is pretty simple in the android studio. You need to follow the very simple step to install this plugin with an android studio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*T8NTt4sJkyHu3FiLwgcmQg.gif" /></figure><p>Now in the next step, you need to connect the device via USB port first time. Please go to <em>wifi setting</em> of your device and click on <em>advanced setting </em>and scroll down here you can get the <em>IP address</em> of your device which needs to connect with adb. Now open command prompt of your system to run the adb to connect to your IP address port. Please check the bellow snap to run the command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*U3_qdWiBqwbFU-wansE5ug.png" /></figure><p>Now go to the android studio and select the tool option on the top of the menu of the android studio and select the ADB WIFI to enable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*oFuM24k13ub042jjqOVVGw.jpeg" /></figure><p>That’s it. Now you do not need to connect to USB cable to debug the application.</p><p><strong>2. ADB Idea</strong></p><p>A plugin for Android Studio and IntelliJ IDEA that speeds up your day to day android development.</p><p>The following commands are provided:</p><ul><li>Uninstall App</li><li>Kill App</li><li>Start App</li><li>Restart App</li><li>Clear App Data</li><li>Clear App Data and Restart</li></ul><p>This plugin is really helping me to develop android application fast. For doing the above task we are going to pick the device and do the corresponding things it’s like irritating. With the help of this plugin, these things become pretty easy and simple. You just need to select any above option to do the task. It is really amazing to develop the application fast. This plugin installation is same as above we have seen. Now let’s check how can we use this plugin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V52rS9IkDN9wiSmOU7uzug.png" /></figure><p><strong>3. JSON To Kotlin Class ​(JsonToKotlinClass)​</strong></p><p>This is a very cool tool for Kotlin developers, it can convert a JSON string to Kotlin data class. The tool could not only recognise the primitive types but also auto create complex types. It’s easily accessible, we provide shortcut keymap ALT + K for Windows and Option + K for Mac, have a try and you’ll fall in love with it! JsonToKotlinClass just makes programming more enjoyable, enjoy coding!</p><p><strong>4.Android Method Count</strong></p><p>A simple Studio/IntelliJ plugin that parses your Android library dependencies and shows the methods count as an handy hint. Using this plugin you can easily manage your <a href="https://developer.android.com/studio/build/multidex.html"><em>dex limit</em></a>. Now handling Multi dex is so easy!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*00aSwI9pgj0fqC-O5wUAcA.png" /></figure><p><strong>5.Rainbow Brackets</strong></p><p>This one adds lovely rainbow colours for the round, square and squiggly brackets. Helpful if you need to simplify a complex code (image below doesn’t present a complex code, it’s just an useless example) .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mCpFT4meLXQSNeVDzKf-sw.png" /></figure><p><strong>6.Name that colour</strong></p><p>Forget about naming colours like ‘red1’, ‘red4’, ‘red_or_pink’. This little gem will propose a closest matching colour name or generate one if you’re really creative with Hex/RGB values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_bXuU99cvskAlEqc-yHa-A.png" /></figure><p>Install the plugins, restart Android Studio and enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e57dd6c61bfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing in-app updates on Android]]></title>
            <link>https://medium.com/@shekhatpriya16/implementing-in-app-updates-on-android-e6e6b3852a3e?source=rss-2034cf90f040------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6e6b3852a3e</guid>
            <category><![CDATA[in-app-update]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Priya Shekhat]]></dc:creator>
            <pubDate>Tue, 22 Oct 2019 04:55:03 GMT</pubDate>
            <atom:updated>2019-10-22T04:55:03.699Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h1aRCXw0T9-FT3xq.png" /></figure><h3>Implementing in-app updates on Android</h3><p>Before starting, please open your play store and check for app updates. What did you found? Almost every app in your mobile device will have some app update. But what to do with this in our blog? I asked you to do this because I want to show you that the user of an app download the app, uses it but he/she never bothers about the update of the app and due to this they might not get the latest feature of the app</p><p>Being an Android developer, we want our users to have the latest version of our app. But in real life, only a few users have the updated version of our app. One of the major reason for not updating the app is that the users don’t have much time to go to the play store to search for updates and then download and install the update.</p><p>To address the same problem, Google has proposed an in-app update system to update the apps. In this feature, you can update your app on your user’s mobile by taking permission from the user. The user can use the app during downloading the update. So, now user need not go to the play store to find the update for your app.</p><p>In this blog, we will learn how to implement the in-app update in our app. So, let’s get started.</p><h4>In-app update</h4><p>The in-app update is a feature of Android Play Core library, that allows you to provide a prompt to the user to offer them an in-app update for a particular app. In simple words, it provides an option to the user which says that an update for the app is available and the user can select if they are interested in updating the app or not.</p><p>Not only that, it provides an option to download the update of the app in the background and once downloaded, install the update and restart the app and the user don’t have to do anything.</p><p>The Play Core Library offers two ways of implementing the in-app update in our mobile application. Let’s look at them, one by one:</p><h4>Flexible Update</h4><p>If your app update contains some features that don’t affect the core functionality of your app, then you can use the flexible update option in your app. In flexible update, the update of the app is download in the background. After downloading, the user will be asked to restart the app. During the restart period, the update of the app will be installed and the app will be restarted. The benefit of using this is, the user can use the app until the download process is finished. A simple flexible update example is shown below:</p><h4>Immediate Update</h4><p>If your app update contains the features that directly affect the core functionality of your app, then you should use the immediate update facility. In the immediate update, a prompt or alert dialog box is opened to ask the user for downloading and installing the update of the app. The user can’t use the app until the downloading, installing and restart will be done. A simple example of an in-app update using the immediate update is shown below:</p><h4>Check for update</h4><p>Before doing the update operation, you must check if some update is available or not. This is done because if the update is not available then we will ask the user to update the app then it will be a bad impression on the user. So, we should first check, if an update is available or not. To check for an update you can use the <strong><em>AppUpdateManager. </em></strong>The code is shown below</p><pre>// Creates instance of the manager. val appUpdateManager = AppUpdateManagerFactory.create(context) // Returns an intent object that you use to check for an update. val appUpdateInfoTask = appUpdateManager.appUpdateInfo // Checks that the platform will allow the specified type of update. appUpdateInfoTask.addOnSuccessListener { appUpdateInfo -&gt; if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE // For a flexible update, use AppUpdateType.FLEXIBLE &amp;&amp; appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE) ) { // Request the update. } }</pre><p>If an update is available and is allowed then from the returned AppUpdateInfo, you can start the app update.</p><h4>Start an update</h4><p>Once you check that if the available or not and if the update is available then the update is allowed or not, if the update is available and the update is allowed then you can start updating the app by using <strong>AppUpdateManager.startUpdateFlowForResult()<em>. </em></strong>Use the below code:</p><pre>appUpdateManager.startUpdateFlowForResult( // Pass the intent that is returned by &#39;getAppUpdateInfo()&#39;. appUpdateInfo, // Or &#39;AppUpdateType.FLEXIBLE&#39; for flexible updates. AppUpdateType.IMMEDIATE, // The current activity making the update request. this, // Include a request code to later monitor this update request. MY_REQUEST_CODE)</pre><p>You should not use this for each and every update you have in your app. Always have some preference. Also, the request for the update should be done only once, unless the update fails. If the update has failed(due to any reason) then you can request for the update again.</p><p>While doing update, you can handle the update related failure or cancellation by using the <strong>onActivityResult()</strong> as follows:</p><pre>fun onActivityResult(requestCode:Int, resultCode:Int, data:Intent) { if (requestCode == MY_REQUEST_CODE){ if (requestCode != RESULT_OK){ log(&quot;Update flow failed! Result code: &quot; + resultCode) // If the update is cancelled or fails, // you can request to start the update again. } } }</pre><p>Here we are getting the <strong><em>MY_REQUEST_CODE </em></strong>from the appUpdateManager. Following are the request codes that you get in the onActivityResult:</p><ul><li><strong>RESULT_OK: </strong>You will get this if the user has accepted the request for update.</li><li><strong>RESULT_CANCELED: </strong>The user has canceled the update or denied for the an update.</li><li><strong>RESULT_IN_APP_UPDATE_FAILED: </strong>Some error has occurred during the update. It may be some error from the user side or some other error.</li></ul><h4>Handling a flexible Update</h4><p>A flexible in-app update can be done by using the <strong>AppUpdateType.FLEXIBLE </strong>while starting an update.</p><p>In the immediate update, the Google play will restart the app after the update is successful. But in a flexible update, the user can use the app and restart the app after using the app. Google play will not automatically restart the app for you. So, in order to restart the app, it is advised to give some alert or some kind of notification to the user to restart the app.</p><p>For example, you can create a snackbar for the same purpose, use the below code:</p><pre>override fun onStateUpdate(state: InstallState) { if (state.installStatus() == InstallStatus.DOWNLOADED) { // After the update is downloaded, show a notification // and request user confirmation to restart the app. popupSnackbarForCompleteUpdate() } ... } /* Displays the snackbar notification and call to action. */ fun popupSnackbarForCompleteUpdate() { Snackbar.make( findViewById(R.id.activity_main_layout), &quot;An update has just been downloaded.&quot;, Snackbar.LENGTH_INDEFINITE ).apply { setAction(&quot;RESTART&quot;) { appUpdateManager.completeUpdate() } setActionTextColor(resources.getColor(R.color.snackbar_action_text_color)) show() } }</pre><p>This will restart the app after proper installation of the update.</p><h4>Handling an immediate update,</h4><p>An immediate in-app update can be done by using the <strong>AppUpdateType.IMMEDIATE </strong>while starting the update.</p><p>During an <strong><em>immediate</em></strong> update, you should handle each and every aspect of the update. During an update, if the user closes the app or your app gets terminated then your app should download and update the app in the background and if your app comes to foreground then you should handle this situation by using the <strong><em>UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS</em></strong> state</p><pre>// Checks that the update is not stalled during &#39;onResume()&#39;. // However, you should execute this check at all entry points into the app. override fun onResume() { super.onResume() appUpdateManager .appUpdateInfo .addOnSuccessListener { appUpdateInfo -&gt; ... if (appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS ) { // If an in-app update is already running, resume the update. manager.startUpdateFlowForResult( appUpdateInfo, IMMEDIATE, this, MY_REQUEST_CODE ); } } }</pre><p>By adding the above lines, the immediate update will be handled in Android applications.</p><h4>Conclusion</h4><p>In this blog, we learned how to use the in-app update feature in our app. We saw the two types of <strong><em>in-app update </em></strong>i.e. the flexible in-app update and the immediate in-app update. Make sure to use the flexible in-app update when your app has very few updates and your update does not affect the core functionality of your app. So, apply this concept in your app and publish some cool updates of your app.</p><blockquote><strong><em>Note: The in-app update feature is available for API level 21 or above and is only available to those apps which are on the play store.</em></strong></blockquote><p>Keep Learning :)</p><p><strong>Team MindOrks</strong></p><p><em>Originally published at </em><a href="https://blog.mindorks.com/implementing-in-app-updates-on-android"><em>https://blog.mindorks.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6e6b3852a3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>