<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: BalaKrishnan</title>
    <description>The latest articles on Forem by BalaKrishnan (@balakrishnanpt).</description>
    <link>https://forem.com/balakrishnanpt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F234973%2Fa155e461-804e-48d2-9410-d59184f8646a.jpeg</url>
      <title>Forem: BalaKrishnan</title>
      <link>https://forem.com/balakrishnanpt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/balakrishnanpt"/>
    <language>en</language>
    <item>
      <title>Andriod Core Concepts</title>
      <dc:creator>BalaKrishnan</dc:creator>
      <pubDate>Sun, 08 Mar 2020 06:50:44 +0000</pubDate>
      <link>https://forem.com/balakrishnanpt/andriod-core-concepts-m4</link>
      <guid>https://forem.com/balakrishnanpt/andriod-core-concepts-m4</guid>
      <description>&lt;p&gt;I started to study the core of android few days back. I feel I am 1 year late to this. Ironically, You don't need to stretch too hard to find it. It is available in Android developer Documentation. &lt;br&gt;
I would recommend you start from (1) Java memory allocation (2) Android Memory management (3) Linux memory management concepts. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://developer.android.com/guide/components/activities/intro-activities"&gt;https://developer.android.com/guide/components/activities/intro-activities&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.android.com/topic/performance/memory-overview"&gt;https://developer.android.com/topic/performance/memory-overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/playlist?list=PLWz5rJ2EKKc9CBxr3BVjPTPoDPLdPIFCE"&gt;https://www.youtube.com/playlist?list=PLWz5rJ2EKKc9CBxr3BVjPTPoDPLdPIFCE&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>android</category>
      <category>java</category>
    </item>
    <item>
      <title>## EasyCam </title>
      <dc:creator>BalaKrishnan</dc:creator>
      <pubDate>Sat, 18 Jan 2020 16:32:15 +0000</pubDate>
      <link>https://forem.com/balakrishnanpt/easycam-1o43</link>
      <guid>https://forem.com/balakrishnanpt/easycam-1o43</guid>
      <description>&lt;p&gt;EasyCam is Android Library that lets you easily integrate a camera feature in your app. &lt;/p&gt;

&lt;p&gt;Goals of EasyCam's are&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Easy implementation of the camera in the app&lt;/li&gt;
&lt;li&gt;Easy Customization of camera view&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This library handles all the logical parts internally and lets you implement a camera view within minutes. In this post, we will see how to integrate EasyCam by calling an Intent and EasyCamFragment - a way to customize your UI as we have handled all logics and memory handling in EasyCamFragment. &lt;/p&gt;

&lt;p&gt;Here is the repo &lt;a href="https://github.com/BalakrishnanPT/EasyCam/blob/feature/EasyCamFragment"&gt;Link&lt;/a&gt; and &lt;a href="https://github.com/BalakrishnanPT/EasyCam/blob/feature/EasyCamFragment/app/"&gt;Sample&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  By Intent
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How does it work?
&lt;/h3&gt;

&lt;p&gt;EasyCam has &lt;strong&gt;Capture and Preview&lt;/strong&gt; page. The Capture page is where the user has a preview of the camera preview (you can look at the image below). Each UI component on this page is customizable. The preview page contains a preview of the image taken. You can go through the list of images you had captured and delete them if required. &lt;/p&gt;

&lt;p&gt;It stores the images taken in the external directory as files and returns in onActivityResult callback.&lt;/p&gt;

&lt;h4&gt;
  
  
  EasyCam offers the following features
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Screen orientation handling&lt;/li&gt;
&lt;li&gt;Output image orientation handling&lt;/li&gt;
&lt;li&gt;Front and Back camera support&lt;/li&gt;
&lt;li&gt;Flash support &lt;/li&gt;
&lt;li&gt;Single and multiple photoshoot mode&lt;/li&gt;
&lt;li&gt;Set minimum and maximum count for multiple shoot mode&lt;/li&gt;
&lt;li&gt;Preview of taken photos&lt;/li&gt;
&lt;li&gt;Manual focus&lt;/li&gt;
&lt;li&gt;Live preview in full screen or fit the aspect ratio&lt;/li&gt;
&lt;li&gt;Delete option in multiple shoot mode
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Add the dependency in module Gradle file
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;implementation 'in.balakrishnan.easycam:easycam:0.0.3-rc5'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;implementation 'androidx.recyclerview:recyclerview:1.1.0'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-rc03'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can trigger the Camera Activity with the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;        &lt;span class="nc"&gt;Intent&lt;/span&gt; &lt;span class="n"&gt;intent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Intent&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;CameraControllerActivity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;intent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setFlags&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Intent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;FLAG_ACTIVITY_SINGLE_TOP&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Intent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;FLAG_ACTIVITY_CLEAR_TOP&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;intent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;putExtra&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"inputData"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CameraBundleBuilder&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setFullscreenMode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setDoneButtonString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Add"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setSinglePhotoMode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setMax_photo&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setManualFocus&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setBucketName&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;getClass&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;getName&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setPreviewEnableCount&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setPreviewIconVisiblity&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setPreviewPageRedirection&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setEnableDone&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setClearBucket&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;createCameraBundle&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
        &lt;span class="n"&gt;startActivityForResult&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;intent&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;214&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You will get the result in the onActivityResult callback&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;   &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;protected&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;onActivityResult&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;requestCode&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;resultCode&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@Nullable&lt;/span&gt; &lt;span class="nc"&gt;Intent&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;super&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;onActivityResult&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;requestCode&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;resultCode&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;requestCode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;214&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resultCode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;RESULT_OK&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
                &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getStringArrayExtra&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"resultData"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;CameraBundleBuilder is a builder class used to configure the Camera View. With simple parameters, you will get the following screen&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_kspQ7J2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/BalakrishnanPT/EasyCam/blob/master/images/orientation_handling.png%3Fraw%3Dfalse" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_kspQ7J2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/BalakrishnanPT/EasyCam/blob/master/images/orientation_handling.png%3Fraw%3Dfalse" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  EasyCam Fragment
&lt;/h2&gt;

&lt;p&gt;EasyCam Fragment contains all logic and configuration required for setting up a Camera View in your app. &lt;/p&gt;

&lt;p&gt;To implement a simple camera view in your app. Extend &lt;code&gt;EasyCamFragment&lt;/code&gt; instead of Fragment. There are three abstract functions you need to override. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;getImageThumb() - You can get the thumbnail image of the captured image. The image is Low in size and quality. It is snap from texture view &lt;/li&gt;
&lt;li&gt;getImage() - You can get an Original image using this function. The Image is high in size and quality. It is from Camera Source&lt;/li&gt;
&lt;li&gt;setTextureResource() - You should return the Texture Id in this callback &lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  How to trigger Image capture?
&lt;/h4&gt;

&lt;p&gt;You can trigger image capture using &lt;code&gt;takePicture()&lt;/code&gt; function in EasyCamFragment. &lt;/p&gt;

&lt;h4&gt;
  
  
  Customization
&lt;/h4&gt;

&lt;p&gt;You can customize the following&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Front and Back Camera selection &lt;/li&gt;
&lt;li&gt;Flash type&lt;/li&gt;
&lt;li&gt;Full-Screen &lt;/li&gt;
&lt;li&gt;Manual Focus&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://github.com/BalakrishnanPT/EasyCam/blob/feature/EasyCamFragment/app/src/main/java/in/balakrishnan/cameramodule/easyCamFragmentExample/EasyCamFragmentExample.java"&gt;Here&lt;/a&gt; is an example &lt;/p&gt;

</description>
      <category>android</category>
      <category>java</category>
      <category>camera</category>
      <category>camera2</category>
    </item>
    <item>
      <title>Looking back at 2019 </title>
      <dc:creator>BalaKrishnan</dc:creator>
      <pubDate>Mon, 30 Dec 2019 08:49:46 +0000</pubDate>
      <link>https://forem.com/balakrishnanpt/looking-back-at-2019-58eh</link>
      <guid>https://forem.com/balakrishnanpt/looking-back-at-2019-58eh</guid>
      <description>&lt;p&gt;2019 has been a year to remember for me. Here I have shared gist of things I have done in 2019 &lt;/p&gt;

&lt;h4&gt;
  
  
  💭Developed app for
&lt;/h4&gt;

&lt;p&gt;1 Android - Mobile&lt;br&gt;
2 Android - Tab &lt;br&gt;
3 Android TV&lt;br&gt;
4 FireStick  &lt;/p&gt;

&lt;h4&gt;
  
  
  📱Worked on different apps
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Streaming app &lt;/li&gt;
&lt;li&gt;Selling / Buying platform app&lt;/li&gt;
&lt;li&gt;Wallpaper app - NFWalls&lt;/li&gt;
&lt;li&gt;Tweetstorm - StormIt&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  👨‍💻Worked with
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Kotlin &lt;/li&gt;
&lt;li&gt;Coroutines&lt;/li&gt;
&lt;li&gt;Dagger&lt;/li&gt;
&lt;li&gt;Jetpack Components

&lt;ul&gt;
&lt;li&gt;RoomDB&lt;/li&gt;
&lt;li&gt;WorkManager&lt;/li&gt;
&lt;li&gt;ViewModel&lt;/li&gt;
&lt;li&gt;LiveData&lt;/li&gt;
&lt;li&gt;Navigation component&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Camera2 API&lt;/li&gt;
&lt;li&gt;Multi module app &lt;/li&gt;
&lt;li&gt;Instant app &lt;/li&gt;
&lt;li&gt;Firebase

&lt;ul&gt;
&lt;li&gt;RealTime DB&lt;/li&gt;
&lt;li&gt;Firebase Auth&lt;/li&gt;
&lt;li&gt;Firebase Dynamic link &lt;/li&gt;
&lt;li&gt;Firebase Analytics and distribution &lt;/li&gt;
&lt;li&gt;Firebase In-App messaging and Cloud messaging (Notification)&lt;/li&gt;
&lt;li&gt;Firebase Remote config&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Maps&lt;/li&gt;
&lt;li&gt;RxJava&lt;/li&gt;
&lt;li&gt;Google drive API integration for backup and restore&lt;/li&gt;
&lt;li&gt;DRM content streaming&lt;/li&gt;
&lt;li&gt;Security

&lt;ul&gt;
&lt;li&gt;SSL Pinning&lt;/li&gt;
&lt;li&gt;RSA content  verification &lt;/li&gt;
&lt;li&gt;AES Encryption / Decryption &lt;/li&gt;
&lt;li&gt;Keystore to store sensitive data&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  🧗Updated
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Moved an App from Java to Kotlin &lt;/li&gt;
&lt;li&gt;Moved an App from ORM Lite to Room DB&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Open source Contribution
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://balakrishnanpt.github.io/EasyCam/"&gt;https://balakrishnanpt.github.io/EasyCam/&lt;/a&gt; - EasyCam Android Library
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/BalakrishnanPT/FileDownload"&gt;https://github.com/BalakrishnanPT/FileDownload&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/BalakrishnanPT/Contacts"&gt;https://github.com/BalakrishnanPT/Contacts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/BalakrishnanPT/FragmentFactoryExample"&gt;https://github.com/BalakrishnanPT/FragmentFactoryExample&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>2019</category>
      <category>android</category>
      <category>architecture</category>
      <category>career</category>
    </item>
    <item>
      <title>RxJava - Make your Async Task Synchronous</title>
      <dc:creator>BalaKrishnan</dc:creator>
      <pubDate>Fri, 18 Oct 2019 12:21:39 +0000</pubDate>
      <link>https://forem.com/balakrishnanpt/rxjava-make-your-async-task-synchronous-2f3n</link>
      <guid>https://forem.com/balakrishnanpt/rxjava-make-your-async-task-synchronous-2f3n</guid>
      <description>&lt;p&gt;In Android framework, We have to do all the time consuming work in background thread. It sounds easy but believe me implementation is pain. If you are using kotlin you can use doAsync or Coroutine but if you are using RxJava you can achieve this without much changes in your code.&lt;br&gt;
 &lt;br&gt;
I have a use case where I have to download the given files in background using WorkManager. Well, here comes the pain, "We have to download all the images and then return success or failure or retry Result to the work manager". How do we hold the thread until Download is complete? &lt;br&gt;
Initially I have solved this with  the CountDownLatch, I implemented and got a working code with that. But it was messy code.&lt;/p&gt;

&lt;p&gt;If you are using RxJava, We can do this with operator "blockingGet()" for this your Observable should be "Single". &lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/BalakrishnanPT/ea6281f15f5dc7882c2e74b3ec46b848"&gt;https://gist.github.com/BalakrishnanPT/ea6281f15f5dc7882c2e74b3ec46b848&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>rxjava</category>
      <category>threading</category>
      <category>java</category>
    </item>
  </channel>
</rss>
