<?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[Dwarsoft - Medium]]></title>
        <description><![CDATA[A blog where we show how technology enables us to build the products and provide top service. We are based in Chennai. - Medium]]></description>
        <link>https://medium.com/dwarsoft?source=rss----63fb4749c25d---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Dwarsoft - Medium</title>
            <link>https://medium.com/dwarsoft?source=rss----63fb4749c25d---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 18:15:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/dwarsoft" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Guide to using Retrofit in MVVM Architecture with Data Binding (Hilt) & RxJava — Kotlin]]></title>
            <link>https://medium.com/dwarsoft/guide-to-using-retrofit-in-mvvm-architecture-with-data-binding-hilt-rxjava-kotlin-1170959ed841?source=rss----63fb4749c25d---4</link>
            <guid isPermaLink="false">https://medium.com/p/1170959ed841</guid>
            <category><![CDATA[rxjava]]></category>
            <category><![CDATA[dwarsoft-mobile]]></category>
            <category><![CDATA[retrofit]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mvvm]]></category>
            <dc:creator><![CDATA[Varun Dwarkani]]></dc:creator>
            <pubDate>Fri, 07 May 2021 20:03:39 GMT</pubDate>
            <atom:updated>2021-05-07T20:03:59.665Z</atom:updated>
            <content:encoded><![CDATA[<h3>Guide to using Retrofit in MVVM Architecture with Data Binding (Hilt) &amp; RxJava — Kotlin</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_7zCtE98Wt8DB7LgVokR9g.png" /></figure><p>Retrofit is one of the most used Android libraries for Networking which Google also recommends us to use in our application. Along with that, this guide will help you understand how to use the Retrofit module, inject it using the Dependency Injection technique (Hilt) in our MVVM Architecture and call the REST APIs and receive callbacks using RxJava all in Kotlin!</p><h3>Implementation —</h3><h3>First Step —</h3><p>We’ll first add the necessary retrofit dependencies along with RxJava and Gson support and OkHttp Interceptor—</p><pre>//OkHTTP and Retrofit<br>def retrofit_version = &quot;2.9.0&quot;<br>implementation &quot;com.squareup.retrofit2:retrofit:$retrofit_version&quot;<br>implementation &quot;com.squareup.retrofit2:adapter-rxjava2:$retrofit_version&quot;<br>implementation &#39;com.squareup.retrofit2:converter-gson:2.9.0&#39;<br>implementation &#39;com.squareup.okhttp3:logging-interceptor:4.9.0&#39;<br>implementation &#39;com.squareup.okhttp3:okhttp-urlconnection:4.4.1&#39;</pre><h3>Second Step —</h3><p>We’ll add Hilt support in our app so that we can inject the Retrofit module into our repository class. To read more about Hilt, I have written an in-depth article on Hilt and its implementation in Java — <a href="https://medium.com/dwarsoft/using-hilt-dependency-injection-to-provide-network-room-instance-6245172c5a57">here</a>. For Kotlin implementation, please follow the below steps —</p><h4>a. Adding Hilt dependency —</h4><pre>//Hilt<br>implementation &quot;com.google.dagger:hilt-android:2.35&quot;<br>kapt &#39;com.google.dagger:hilt-android-compiler:2.35&#39;</pre><h4>b. Adding Hilt Annotations —</h4><p>We’ll be required to add few annotations. First, we will add one in the class which extends the Application class — <strong>‘@HiltAndroidApp’. </strong>In each of our activity/fragments, we will add — <strong>‘@AndroidEntryPoint’. </strong>In our view model, we’ll add the — <strong>‘@HiltViewModel’. </strong>All set!</p><p>Now, we will create a Retrofit module which we will be able to inject into our repository —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6000693dea30fdccfe835c3f63c5abb5/href">https://medium.com/media/6000693dea30fdccfe835c3f63c5abb5/href</a></iframe><h3>Third Step —</h3><p>To use Retrofit, we will need to define an interface where we can specify the endpoint, method, and the parameters we’ll be passing —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d4fdbd546971581669f03232780118b2/href">https://medium.com/media/d4fdbd546971581669f03232780118b2/href</a></iframe><p>Here you will see that we have specified an annotation that indicates that it is a POST method call and the endpoint is attached to the APIConstant which we used while constructing the Retrofit Builder in the Hilt module. In the parameters of the function, we will pass the parameters we want to pass in the body annotated with — <strong>‘@Field(“…”)’. </strong>The annotation — <strong>‘@FormUrlEncoded’ </strong>helps us pass the parameters as Form Encoded in the body of the API request.</p><p>For the response, we have specified the model class as — <strong>‘NewsAPIResponse’.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/308d5f1edfab348e7619d66f47597387/href">https://medium.com/media/308d5f1edfab348e7619d66f47597387/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31e9282c0c4de2b4ca758a7729dc9664/href">https://medium.com/media/31e9282c0c4de2b4ca758a7729dc9664/href</a></iframe><h3>Fourth Step —</h3><p>In the retrofit module, first, we will inject the ApiService of the Retrofit module using Hilt in our repository (constructor injection) —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b5dd7da60ec3de10a3821d82c818662/href">https://medium.com/media/5b5dd7da60ec3de10a3821d82c818662/href</a></iframe><p>We will also inject the NewsRepository in our ViewModel —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4012eaee3571c7d6bd681c6a6c8c0f73/href">https://medium.com/media/4012eaee3571c7d6bd681c6a6c8c0f73/href</a></iframe><p>In the repository, we will consume the — <strong>‘getNews()’ </strong>function we defined in the ApiService interface. And then we will use the <strong>getNews()</strong> function of our <strong>NewsRepository </strong>in the fragment/activity as —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99e08cbe15d6e59d5fbdffda8e19994c/href">https://medium.com/media/99e08cbe15d6e59d5fbdffda8e19994c/href</a></iframe><h3>Conclusion —</h3><p>Tada! Now we are making network calls using Retrofit in our MVVM Architecture written in Kotlin with Data Binding and RxJava callbacks! Instead of RxJava, we can also make use of Kotlin Coroutines which is a concurrency design pattern for asynchronous programming.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1170959ed841" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dwarsoft/guide-to-using-retrofit-in-mvvm-architecture-with-data-binding-hilt-rxjava-kotlin-1170959ed841">Guide to using Retrofit in MVVM Architecture with Data Binding (Hilt) &amp; RxJava — Kotlin</a> was originally published in <a href="https://medium.com/dwarsoft">Dwarsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Journey & Tips on converting Java Android project to 100% Kotlin — Kotlin 101]]></title>
            <link>https://medium.com/dwarsoft/my-journey-tips-on-converting-java-android-project-to-100-kotlin-kotlin-101-1f11e105144d?source=rss----63fb4749c25d---4</link>
            <guid isPermaLink="false">https://medium.com/p/1f11e105144d</guid>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[kotlin-app-development]]></category>
            <category><![CDATA[android-kotlin-basic]]></category>
            <category><![CDATA[dwarsoft]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Varun Dwarkani]]></dc:creator>
            <pubDate>Sun, 02 May 2021 16:27:42 GMT</pubDate>
            <atom:updated>2021-05-03T05:11:50.386Z</atom:updated>
            <content:encoded><![CDATA[<h3>My Journey &amp; Tips on converting Java Android project to 100% Kotlin — Kotlin 101</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ublko-Ub1zSqq9lrg3nLA.png" /><figcaption>Converting Java Android codebase to Kotlin and Kotlin 101</figcaption></figure><p>Recently I decided to start learning Kotlin by converting one of my project’s code from Java to Kotlin (PS — Android Studio proved helpful in doing so). With this, I was able to learn much of Kotlin quickly and also see it in action on one of my already deployed apps on Playstore.</p><h3>Basic Steps —</h3><ol><li>The first thing I did is to add Kotlin support and dependencies to my already existing project. To do so, Google has good documentation available <a href="https://developer.android.com/kotlin/add-kotlin">here</a>. Essentially, we will add kotlin gradle plugin in the project-level build.gradle file</li></ol><pre>ext <strong>{<br>    </strong>kotlin_version = &#39;1.4.32&#39;<br><strong>}</strong></pre><pre>classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version&quot;</pre><p>And in the app’s build.gradle we will add —</p><pre>apply plugin: &#39;kotlin-android&#39;<br>apply plugin: &#39;kotlin-kapt&#39;</pre><pre>implementation &quot;org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version&quot;</pre><p>If you were already using Room or Hilt libraries in Java, you will have to change the annotation processor dependency to kapt —</p><pre>//Hilt<br>kapt &#39;com.google.dagger:hilt-android-compiler:2.35&#39;<br>//Room<br>kapt &quot;androidx.room:room-compiler:$room_version&quot;</pre><p>2. Now to convert the existing Java file to Kotlin, it can be done in multiple ways —</p><p>a. Select the file, click on <strong>Code </strong>from the Menu bar and select the <strong>‘Convert Java File to Kotlin File’ </strong>option to convert the Java file to Kotlin.</p><p>b. Right-click on the file and select the ‘<strong>Convert Java File to Kotlin File’ </strong>option.</p><p>c. It will help if you remember the shortcut — ‘<strong>Ctrl + Alt + Shift + K’ </strong>since we will be converting a lot of files.</p><p><strong>Note — </strong>Start with converting simple Java classes (Ex — Activity which has ideally no code, Splash screens, Model classes, etc) so it will be easy to convert a few, learn the syntax, and deploy it with Kotlin code included.</p><h3>Terminologies —</h3><p>Let’s learn a few basic Kotlin syntax to help understand the code which was converted by the Android Studio for us —</p><h4><strong>Variables —</strong></h4><ol><li><strong>var — </strong>Variables defined with var qualifier are <strong>Mutable variables. </strong>They can be assigned values multiple times. When a value is assigned the first time, it takes that value’s type as the variable’s type. Ex —</li></ol><pre>var newstitle: String = &quot;News Title&quot;</pre><p>2. <strong>val — </strong>Variables defined with val qualifier are <strong>Immutable variables. </strong>They can be initialized only once and are very similar to Java’s <strong>final </strong>declared variables.</p><pre>private val LOGGER = MyApplication::class.<em>java</em>.<em>name</em></pre><p>3. <strong>lateint — </strong>It is used to define variables with non-nullable types indicating that they will be declared later. We will understand the exact use case of it when we understand the various nullable operators below.</p><pre>lateinit var courseName: String</pre><p>4. <strong>const — </strong>It is used to define constant variables. Pretty similar to <strong>static</strong> in Java. These are also Immutable variables and differ from <strong>val </strong>as these are known at Compile Time.</p><pre>const val CONNECT_TIMEOUT: Long = 30000</pre><p>5. <strong>lazy — </strong>Another way to declare variables is by using the <strong>by lazy { … } </strong>block. This will declare the variable when it is called the first time, hence the lazy keyword meaning. It can be used only on <strong>val</strong> and <strong>lateint var</strong>.</p><pre><strong>private</strong> val heavyObject: HeavyClass by lazy {         <br>    HeavyClass()<br>}</pre><h3>Operators —</h3><p>Kotlin is null-safe and that is probably one of the biggest advantages of it over Java. To use that, we have few operators defined —</p><ol><li><strong>!! operator — </strong>This is used to ensure the variable is not null. If it is null, Kotlin throws an NPE for us. Use this when you are sure that the variable’s value should not be null and if it is, it is because of some error</li></ol><pre>return webViewViewModel!!</pre><p>2. <strong>? and ?. operator — </strong>The ? operator is used to say that the variable can have null values. These are primarily used when we declare the <strong>var </strong>variables and initialize them to null with a <strong>? </strong>The <strong>?. </strong>operator can be used in the chain when we try to access value from Network response or model classes where the condition can be like — ObjectA is not null then ObjectA.ObjectB and if ObjectB is not null then ObjectB.ObjectC.</p><pre>student?.department?.teacher?.name</pre><p>3. <strong>Typecasting —</strong></p><p>For typecasting in Kotlin, we will use the <strong>as </strong>operator. It can be coupled with a nullable operator<strong>? — as Type?</strong>. If the cast is not valid, it will return null.</p><pre>val navHostFragment = <em>supportFragmentManager</em>.findFragmentById(R.id.<em>navHost</em>) as NavHostFragment?</pre><h3><strong>Expressions —</strong></h3><p>One new expression I liked in Kotlin is — <strong>when expression. </strong>It can be used similarly as the switch from Java but also has the capability to support different types of evaluation, multiple conditions together separated with a comma and also include non-compile time constants which cannot be done using the switch in Java and we end up using If-Else If blocks.</p><pre>when (teamName) {<br>    &quot;CSK&quot; -&gt; return Teams.<em>CSK<br>    </em>&quot;MI&quot; -&gt; return Teams.<em>MI<br>}</em></pre><h3>Methods —</h3><p>In Kotlin, methods (functions) are defined in a little differen way than Java’s convention ‘<strong>modified returnType funName(args…) { … } —</strong></p><pre>modifier fun funName(args...): returnType { ...}</pre><pre>Ex-<br>private fun getEmojiResourceID(integer: Int?): Int {<br>    ....<br>}</pre><p><strong>‘@JvmStatic’ — </strong>Annotation is used to ask the class to define two methods — one static and another which is called from the instance of a class.</p><h3>Extend &amp; Implement classes —</h3><p>Kotlin makes it easier to Extend and Implement Classes.</p><p>Instead of Java’s extend ClassName, implements ClassName, in Kotlin we have —</p><pre>Class : Extend(), ImplementA, ImplementB { ... }</pre><h3><strong>Companion Object —</strong></h3><p>You will notice that your <strong>final static </strong>variables declared will be put under a block of <strong>companion object —</strong></p><pre>companion object {<br>    private val LOGGER = MyApplication::class.<em>java</em>.<em>name<br>    </em>operator fun get(activity: Activity): MyApplication {<br>        return activity.<em>application </em>as MyApplication<br>    }<br>}</pre><p>All the static methods, variables that can be called without instantiating an object of the class will be present inside this block. The static methods will have <strong>operator </strong>keywords attached in front.</p><h3><strong>Object Class —</strong></h3><p>If the class has only static variables and methods, the class definition will be converted to the <strong>object ClassName</strong>. These are more like Singleton classes. These classes cannot be instantiated and the variables and methods can be accessed directly using the class name.</p><pre>object Constants {<br>    const val GOOGLE_SIGN_IN = 30<br>}</pre><h3><strong>Modifier —</strong></h3><p>Kotlin introduces a new modifier called — <strong>‘internal’. </strong>The<strong> internal</strong> keyword is used to define variables and methods with module access. If our code has multiple modules, the variables and methods will not be exposed beyond the current module.</p><h3>String Operations —</h3><p>String operations are made easy in Kotlin. Now if we want to append a variable in a hard-coded string, we can do that like —</p><pre>val facebookUrl = &quot;https://www.facebook.com/<strong>$FACEBOOK_PAGE_ID</strong>&quot;</pre><p>Where <strong>FACEBOOK_PAGE_ID </strong>is a variable.</p><p>We can also use, <strong>.plus() </strong>or <strong>‘+’ </strong>operator outside the double-quotes.</p><h3>Let —</h3><p>Let is Kotlin’s scope function which allows us to execute code block within the context of an object.</p><pre>var upperStr = str.let { it.toUpperCase()}</pre><h3>Open —</h3><p>In Kotlin, all the classes are <strong>final </strong>by default and so they cannot be inherited. To make a class inheritable, we need to define the class with the keyword — ‘<strong>open’.</strong></p><h3>Data Class —</h3><p>Data class is one of the special features of Kotlin. Data classes are for one purpose — <strong>To hold data.</strong> If we define a class with the <strong>‘data’</strong> keyword, it would automatically generate the getters, setters, hashCode(), equals(), toString(), copy(), and componentN() methods used to destructure the variables from the class.</p><pre><strong>data</strong> <strong>class</strong> User(<strong>val</strong> name: String, <strong>val</strong> age: Int)</pre><h3><strong>Sealed Class —</strong></h3><p>Sealed classes are used to define restricted class hierarchies and the constructors are private by default. It cannot be instantiated and differs from Enum by allowing us to create instances with different types.</p><pre><strong>sealed</strong> <strong>class</strong> Expr <br><strong>data</strong> <strong>class</strong> Const(<strong>val</strong> number: Double) : Expr() <br><strong>data</strong> <strong>class</strong> Sum(<strong>val</strong> e1: Expr, <strong>val</strong> e2: Expr) : Expr() <br><strong>object</strong> NotANumber : Expr()</pre><h3><strong>Constructors —</strong></h3><p>The constructors in Kotlin have become much more concise and one-liner. Ex —</p><pre>class NewsDataSource <strong>internal constructor(private val newsRepository: NewsRepository)</strong> : PageKeyedDataSource&lt;Int, News&gt;() {<br>    ...<br>}</pre><h3>Others —</h3><ol><li>We don’t use the function call to access any variable. It is done using the property access syntax. Ex — Instead of <strong>authenticationBinding.getRoot()</strong>, we use <strong>authenticationBinding.<em>root</em></strong><em>.</em></li><li>Instead of <strong>‘@Override’</strong> in Java, we directly use — <strong>‘override fun ..’ </strong>in Kotlin.</li><li>We do not have the <strong>new </strong>keyword in Kotlin. Instead, we call the constructor method directly as a normal method call.</li><li>Semi-colons are optional in Kotlin!</li><li><strong>‘@Nullable’ — </strong>annotations used in Java to define null arguments are replaced by using the <strong>‘?’ operator </strong>in Kotlin.</li><li><strong>init { … } — </strong>init blocks can be used as secondary constructors and there can be more than one init block.</li><li>Android-specific — We now get <strong>requireActivity() </strong>which can be used in Fragments to get Activity (If not available, it throws ex) and <strong>requireView() </strong>methods.</li></ol><h3>Conclusion —</h3><p>I have been meaning to study Kotlin for a long time and it is well-known fact that if we learn it practically we tend to learn it at a faster pace so this is what I did. I took a recently published application which I wrote in 100% Java and converted it to Kotlin within 3–4 hours. It was a bit overwhelming at the beginning but by the end of 1st hour, I was starting to get the hang of Kotlin&#39;s syntax and understand the code flow as well as understanding the syntax of Kotlin. Kotlin does seem a bit easy and more powerful than Java 8. It helps us write concise code and increases our speed since it generates a lot of boilerplate code for us.</p><p>To help understand more on Kotlin and the advanced concepts, do refer to the Kotlin official documentation <a href="https://kotlinlang.org/docs/home.html">here</a>.</p><p>To expand your knowledge and learn more Kotlin for Android, you can start with learning about <strong>Coroutines </strong>and <strong>Flows </strong>which really enhances asynchronous programming to another level.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f11e105144d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dwarsoft/my-journey-tips-on-converting-java-android-project-to-100-kotlin-kotlin-101-1f11e105144d">My Journey &amp; Tips on converting Java Android project to 100% Kotlin — Kotlin 101</a> was originally published in <a href="https://medium.com/dwarsoft">Dwarsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Hilt (Dependency Injection) To Provide Network & Room Instance]]></title>
            <link>https://medium.com/dwarsoft/using-hilt-dependency-injection-to-provide-network-room-instance-6245172c5a57?source=rss----63fb4749c25d---4</link>
            <guid isPermaLink="false">https://medium.com/p/6245172c5a57</guid>
            <category><![CDATA[dwarsoft-mobile]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[hilts]]></category>
            <dc:creator><![CDATA[Varun Dwarkani]]></dc:creator>
            <pubDate>Mon, 26 Apr 2021 09:20:29 GMT</pubDate>
            <atom:updated>2021-04-26T09:20:29.169Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a1Y3Xwyi4qNNGclGYEDQng.png" /><figcaption>Hilt — Dependency Injection library part of Jetpack Library.</figcaption></figure><h3>Why use Dependency Injection in our project?</h3><p><strong>Dependency Injection</strong> is a common technique used across the programming world to provide classes instead of writing or creating them by ourselves. This also prevents having boilerplate code and trying to instantiate or maintain instances of classes by ourselves. It encourages code reusability and maintains our code architecture well.</p><h3>Hilt Introduction —</h3><p><a href="https://developer.android.com/training/dependency-injection/hilt-android">Hilt</a> is a dependency injection library provided by Google (Jetpack Libraries) which helps reduce the boilerplate code for manual dependency injection in our project. It is built on top of <strong>Dagger</strong> (another Google library) to simplify and ease the code with pre-defined bindings, qualifiers, and scope annotations.</p><h3>Implementation —</h3><p>In this article, I will use Hilt to inject Network (Retrofit here) instance and Room Instance to access the local database easily in our MVVM Architecture codebase.</p><h3>First Step —</h3><p>The First Step in the process would be to add the necessary Hilt related dependencies —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb2dc6e88c219e28c5b2c2083ed4445e/href">https://medium.com/media/eb2dc6e88c219e28c5b2c2083ed4445e/href</a></iframe><h3>Second Step —</h3><p>Now we will define an Application class in our project. Create a new class and extend it with ‘<strong>Application</strong>’. Now in the AndroidManifest.xml, add an entry for the name in the &lt;application&gt; tag and specify the application file as its value.</p><p>We will now annotate the class with ‘<strong>@HiltAndroidApp</strong>’ annotation. This is done to trigger Hilt’s code generation and also maintains a base class for application-level dependency injections. This will also attach itself to the Application lifecycle, creating it on — onCreate and destroying it on — onDestroy of the Application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b66a5d7bacc6b502a545d2f8b0f461f3/href">https://medium.com/media/b66a5d7bacc6b502a545d2f8b0f461f3/href</a></iframe><h3><strong>Third Step —</strong></h3><p>Now we will add annotations to our Activity as well as Fragments.</p><p>We will annotate our Activities and Fragments with — <strong>‘@AndroidEntryPoint’ </strong>annotation. This will provide dependencies to other classes in our project.</p><p>Other types of annotations are captured <a href="https://developer.android.com/training/dependency-injection/hilt-android#android-classes">here</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/502fb6f2f8cba59a79e30393a57b57f6/href">https://medium.com/media/502fb6f2f8cba59a79e30393a57b57f6/href</a></iframe><p><strong>Note</strong> — If a fragment annotated with ‘@AndroidEntryPoint’, the annotation is to be added in all the activities where the fragment is used.</p><h3>Fourth Step —</h3><p>Now we will create our module and use it to inject the instance directly in our Repository class (In MVVM — Data Access is handled in Repository class). To do so, we will use few other annotations — ‘@Module’, ‘@InstallIn’, ‘@Provides’, and ‘@Singleton’.</p><p><strong>‘@Module’</strong> annotation is used for injecting modules that cannot be constructor-injected. To simply this, we can constructor inject something we own but in our case, Retrofit is an external library that we do not own. Thus we will provide an instance of it and use ‘@Module’ to provide it to our Android classes.</p><p><strong>‘@InstallIn’</strong> annotation is used to define which level should it be injected. Ex — Application level, Activity level, ViewModel level. It will obey the lifecycle of the specified level. We have used <strong>SingletonComponent. </strong>For other types, please refer <a href="https://developer.android.com/training/dependency-injection/hilt-android#generated-components">here</a>.</p><p><strong>‘@Provides’</strong> annotation is used where we cannot constructor-inject a type and <strong>‘@Singleton’</strong> is used to define that only one instance should exist.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bd70fec31625a0a1e6fc8d6052bef80/href">https://medium.com/media/8bd70fec31625a0a1e6fc8d6052bef80/href</a></iframe><p>Similarly, for Room, we can create another module like —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64cded42dc24b2e6d4f222cb020f031f/href">https://medium.com/media/64cded42dc24b2e6d4f222cb020f031f/href</a></iframe><h3>Fifth Step —</h3><p>The final step now is to use the instances we have provided. To do so, we will now move to our Repository class and straightaway <strong>inject</strong> the instance in the constructor of the Repository class using <strong>‘@Inject’</strong> annotation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a66767b9b60ce83adf42b2f49cf3217/href">https://medium.com/media/5a66767b9b60ce83adf42b2f49cf3217/href</a></iframe><p>And that’s it! No more instantiating Retrofit and Room DB every time or maintaining it by yourself. It is now going to be magically (not so magical as it felt in the beginning) provided to you by Hilt.</p><p>Hilt can also be used to inject different types of Interceptors for specific requests. To read more, please visit the <a href="https://developer.android.com/training/dependency-injection/hilt-android">official docs on Hilt by Google</a>.</p><p>Hilt is still in beta so please use it with caution as there can be bugs that could disrupt our application. On a personal note, I’ve used it in a production project and it works quite well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6245172c5a57" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dwarsoft/using-hilt-dependency-injection-to-provide-network-room-instance-6245172c5a57">Using Hilt (Dependency Injection) To Provide Network &amp; Room Instance</a> was originally published in <a href="https://medium.com/dwarsoft">Dwarsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Pagination Library For Android Recycler View Pagination In MVVM Architecture]]></title>
            <link>https://medium.com/dwarsoft/using-pagination-library-for-android-recycler-view-pagination-in-mvvm-architecture-8ae077c8ca48?source=rss----63fb4749c25d---4</link>
            <guid isPermaLink="false">https://medium.com/p/8ae077c8ca48</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[dwarsoft-mobile]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-apps]]></category>
            <dc:creator><![CDATA[Varun Dwarkani]]></dc:creator>
            <pubDate>Sun, 25 Apr 2021 11:01:17 GMT</pubDate>
            <atom:updated>2021-04-25T11:01:17.585Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R9NzL2sWy2VySzwUZwfsXg.png" /><figcaption>Android Paging Library — Part of Android Jetpack Libraries</figcaption></figure><p>When using the recycler view, we would always face some kind of issues with respect to performance and smoothness. One such issue occurs because of loading many items together which causes network and performance bottleneck. To prevent this, Android introduced a ‘<strong>Paging Library</strong>’ under <strong>Jetpack Libraries</strong>. This library helps us in implementing pagination to our Recycler View irrespective of the data source.</p><p>If you have previously used your own pagination logic using Recycler View listeners, this library would help ease it for you and with MVVM Architecture, it will be a lot cleaner than before.</p><p>I assume you have prior knowledge of implementing Recycler View in MVVM Architecture.</p><p>Here in this example, we are trying to load upcoming cricket matches from our backend using API calls.</p><p>Let’s talk Implementation!</p><h3>First Step —</h3><p>Add the required dependencies for the Pagination Library-</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd34d646fae06affd07b9410c01e5652/href">https://medium.com/media/dd34d646fae06affd07b9410c01e5652/href</a></iframe><h3>Second Step —</h3><p>Add a Recycler View inside the XML and use a custom BindingAdapter to pass in an adapter. We define the adapter as below —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3bdd91f88d7cb0163248854c8e43868/href">https://medium.com/media/b3bdd91f88d7cb0163248854c8e43868/href</a></iframe><p>All are basic stuff except we use DiffUtil.ItemCallback to check if the items are the same and pass them in the constructor. We also extend our adapter class with — ‘<strong>PagedListAdapter</strong>’ instead of ‘RecyclerView.Adapter’ directly.</p><p>Once done with the adapter, we will now create two important components —</p><ol><li>DataSource</li><li>DataFactory</li></ol><h3>Third Step —</h3><p>We will create a class that extends <strong>DataSource</strong>. The DataSource class is where the business logic is written to fetch the data and return it. We can create a DataSource class by extending either <a href="https://developer.android.com/reference/androidx/paging/PageKeyedDataSource"><strong>PageKeyedDataSource</strong></a><strong> </strong>(Used to load previous/next pages), <a href="https://developer.android.com/reference/androidx/paging/ItemKeyedDataSource"><strong>ItemKeyedDataSource</strong></a><strong> </strong>(Uses N-1 data items to load N item), or <a href="https://developer.android.com/reference/androidx/paging/PositionalDataSource"><strong>PositionalDataSource</strong></a><strong> </strong>(Load pages of requested size at arbitrary positions).</p><p>In this example, we will use <a href="https://developer.android.com/reference/androidx/paging/PageKeyedDataSource">PageKeyedDataSource</a>.</p><p>There are three methods which we will override — <strong>loadInitial, loadBefore, loadAfter</strong>. As the name suggests, these methods are used to load the initial list, the previous page, and the next page respectively. We will use a static <strong>PAGE_SIZE </strong>Int and return the key in the callback of each method we override.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8eebca1bf949cc7869e88ea23aabfbb0/href">https://medium.com/media/8eebca1bf949cc7869e88ea23aabfbb0/href</a></iframe><h3>Fourth Step —</h3><p>We will create our <strong>DataFactory </strong>extending — ‘DataSource.Factory’.</p><p>Here, we have used the create method to initialize our DataSource class. The factory will be used in the <strong>LivePagedListBuilder </strong>which we will use to update our RecyclerView from View.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c17ba5e8bb703194cf75bd43fd9247bc/href">https://medium.com/media/c17ba5e8bb703194cf75bd43fd9247bc/href</a></iframe><h3>Fifth Step —</h3><p>Once done with creating DataSource and DataFactory, we will now used the PagedListConfig to initialize paging which uses the DataFactory inside our ViewModel class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7aa079be097c0b835a1784203b55fbe/href">https://medium.com/media/f7aa079be097c0b835a1784203b55fbe/href</a></iframe><p>We will define if we need null placeholders to show up and what the page size would be. Then we will create a LiveData of the ‘<strong>PagedList</strong>’ type and initialize it with the ‘<strong>LivePagedListBuilder</strong>’.</p><h3>Sixth Step —</h3><p>In the View, we will observe the LiveData and submit data to the created adapter —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d8edcbc1342dd6fcd567ee7580a7cb9/href">https://medium.com/media/7d8edcbc1342dd6fcd567ee7580a7cb9/href</a></iframe><p>Voila! We are done with using the new Paging Library from the Android Jetpack Library in our application.</p><p>Here’s a small animation of how the data flows—</p><figure><img alt="Android Paging Library" src="https://cdn-images-1.medium.com/max/800/1*m3NTNFJZCtMHw4z94v1s-g.gif" /><figcaption>Android Paging Library</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ae077c8ca48" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dwarsoft/using-pagination-library-for-android-recycler-view-pagination-in-mvvm-architecture-8ae077c8ca48">Using Pagination Library For Android Recycler View Pagination In MVVM Architecture</a> was originally published in <a href="https://medium.com/dwarsoft">Dwarsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run Multiple Android Studio Versions On A Single Machine]]></title>
            <link>https://medium.com/dwarsoft/run-multiple-android-studio-versions-on-a-single-machine-2a7d00045813?source=rss----63fb4749c25d---4</link>
            <guid isPermaLink="false">https://medium.com/p/2a7d00045813</guid>
            <category><![CDATA[dwarsoft-mobile]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Varun Dwarkani]]></dc:creator>
            <pubDate>Sat, 24 Apr 2021 18:00:54 GMT</pubDate>
            <atom:updated>2021-04-24T18:00:53.959Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZI9zNxmnD170dJhGq32RQw.png" /></figure><p>When working on multiple projects, particularly if the project is quite old and a huge team is working on it, we will have to use the legacy Android Studio version to run the project. But at the same time, if we are working on any recently created project, it would not be compatible with the old Android Studio version. We will end up in a confused state to deciding which Android Studio version to run on our machine</p><p>But no worries, there’s a simple and quick way with which we can run multiple versions of Android Studio on our machine.</p><p>Here are the steps to do it-</p><ol><li>Navigate to <a href="https://developer.android.com/studio#downloads">https://developer.android.com/studio#downloads</a> and download the zip versions of the different Android Studio you would want to run.</li><li>Extract the zip files to the desired location.</li><li>Now just open the extracted zip file, navigate to the bin directory and run the studio64.exe file. Voila! You will now be able to run multiple Android Studio versions on your machine.</li><li>Bonus Step — Pin the versions to Taskbar so that the next time you can run it quite easily.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a7d00045813" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dwarsoft/run-multiple-android-studio-versions-on-a-single-machine-2a7d00045813">Run Multiple Android Studio Versions On A Single Machine</a> was originally published in <a href="https://medium.com/dwarsoft">Dwarsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Reverse Engineer An Android Application In 3 Easy Steps | Dwarsoft Mobile]]></title>
            <link>https://medium.com/dwarsoft/how-to-reverse-engineer-an-android-application-in-3-easy-steps-dwarsoft-mobile-880d268bdc90?source=rss----63fb4749c25d---4</link>
            <guid isPermaLink="false">https://medium.com/p/880d268bdc90</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[dwarsoft-mobile]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-developers]]></category>
            <category><![CDATA[android-security]]></category>
            <dc:creator><![CDATA[Varun Dwarkani]]></dc:creator>
            <pubDate>Sat, 12 Sep 2020 18:34:36 GMT</pubDate>
            <atom:updated>2020-09-12T18:34:36.900Z</atom:updated>
            <content:encoded><![CDATA[<h3>How To Reverse Engineer An Android Application In 3 Easy Steps</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*nGOlrpKMhkyWZ7-v9DFUNA.png" /><figcaption>Reverse Engineer Android Application</figcaption></figure><p>Many beginners or even intermediate Android developers fail to realize that the Android app they build and ship can be reverse engineered to a greater extent. If you are one of the developers who think hard-coding secret keys or even storing it in build.gradle file will prevent it from going into the hands of hackers or other developers, you are wrong.</p><p>Security has never been easy and the very first rule is to never trust the security on the client-side. The Client-side is not an environment we control and thus we should not rely on it by hard-coding or storing secrets that can disrupt our system. So the best way to ensure you do not end up getting caught by developers and hackers is to reverse engineer the application by yourself and fix the issues if possible.</p><blockquote><strong>Interesting Incident </strong>— Once I was working on an Android Application which required a mathematical formula to be used in a feature. Disliking math to the core, I found it more easy and interesting to reverse engineer one of the competitors application and then I took out the Math formula from the code successfully! :p</blockquote><p>So, let’s get started. For reverse engineering an application, we would need a few things beforehand —</p><ol><li>APK of the application.</li><li>Some set of codes to execute.</li><li>Java Decompiler Tool (JD JUI in this article) to view the decompiled code.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*ZRVvF37mrQLSjJEqNlsaRw.jpeg" /><figcaption>Basic understanding of the Android app. Source — <a href="https://www.slideshare.net/PranayAiran1/reverse-engineering-android-apps">Pranay Airan</a>.</figcaption></figure><h3><strong>First Step —</strong></h3><p>We would need the APK of the application we want to reverse-engineering. There are many ways to do that but I will suggest a simple way here. Download the app <a href="https://play.google.com/store/apps/details?id=com.ext.ui"><strong>Apk Extractor </strong></a>on your device and select the application from the list inside the application. Once done, open any File Explorer and go to the <strong>ExtractedApks </strong>folder present in the Internal Storage directory. There, you will find the APK. Copy that APK to your system and we will proceed with the below steps.</p><h3><strong>Second Step —</strong></h3><p>Once we have the APK, we will reverse it to know and see the code. That will enable us and give us insights about the structuring of the code as well as find the security measures they have taken to avoid facing a reverse engineering attack.</p><p>Here, we will rename our {app}.apk file to {app}.zip and extract it. Inside the extracted folder, we will find the classes.dex file which contains the application code.</p><blockquote>A DEX file is an executable file which contains the compiled code and runs on the Android platform.</blockquote><p>Now, we will use the classes.dex file we took from the APK zip file and convert it to JAR. For doing that, we can use <strong>‘dex2jar’ </strong>open-source tool available <a href="https://github.com/pxb1988/dex2jar"><strong>here</strong></a><strong>. </strong>Head over to the release section and download the latest available zip file and extract it. Copy the extracted classes.dex file and paste it inside the <strong>‘dex2jar-x.x’ </strong>directory.</p><p>Open Terminal on your machine and head over to the <strong>‘dex2jar-x.x’ </strong>directory. Now we will run the command -</p><blockquote><strong>d2j-dex2jar.bat classes.dex</strong></blockquote><p>This will convert the classes.dex file to a JAR file which we can view using any Decompiler Tool.</p><h3><strong>Third Step —</strong></h3><p>We will use <strong>JD JUI </strong>which is a simple Java Decompiler tool. You can get it from <a href="http://java-decompiler.github.io/"><strong>here</strong></a>. Download and extract the zip. Run the <strong>jd-gui.exe </strong>and open the dex file and Voila! We reverse-engineered the application!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XGymjMKtUBmPylJ9wiWb7w.png" /><figcaption>Decompiled Android App Source Code</figcaption></figure><p>In case we are meeting for the first time, I am Varun — Founder of <a href="https://dwarsoft.com/"><strong>Dwarsoft</strong></a>. We at Dwarsoft turn ideas into reality with the speed of light and the same perfection of Dettol killing the germs. Hit me up with your ideas and let us make it a reality together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=880d268bdc90" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dwarsoft/how-to-reverse-engineer-an-android-application-in-3-easy-steps-dwarsoft-mobile-880d268bdc90">How To Reverse Engineer An Android Application In 3 Easy Steps | Dwarsoft Mobile</a> was originally published in <a href="https://medium.com/dwarsoft">Dwarsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SKip — Attendance Cum Bunk Manager Application]]></title>
            <link>https://medium.com/dwarsoft/skip-attendance-manager-application-d439a5e8247b?source=rss----63fb4749c25d---4</link>
            <guid isPermaLink="false">https://medium.com/p/d439a5e8247b</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[dwarsoft]]></category>
            <category><![CDATA[attendance]]></category>
            <category><![CDATA[play-store]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Varun Dwarkani]]></dc:creator>
            <pubDate>Thu, 03 Sep 2020 11:55:21 GMT</pubDate>
            <atom:updated>2020-09-03T11:55:21.877Z</atom:updated>
            <content:encoded><![CDATA[<h3>SKip — Attendance Cum Bunk Manager Application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HugdbfjCJ8Xha4lQmMn3yQ.png" /><figcaption>SKip — Attendance Manager application</figcaption></figure><p>Waking up early to attend school or college on a Monday morning is probably the most dreaded dream of every student. We always get the thought of skipping classes and getting some extra sleep but, the thought vanishes as soon as we try calculating our Attendance percentage and realize that we might be lagging on the minimum percentage mark. Some students who are not lazy enough, try to track their attendance on the back of their all-in-one notebook or by using any notes app. But it all fails after some time due to the frustration of doing so many calculations. Keeping track of subject-wise attendance and calculating the percentage to predict how many hours they can SKIP isn’t easy. And at some point, we all end up dreaming of having an Attendance Manager application to help us in doing so.</p><p>And so, this is what made us come up with a solution. We built a revolutionary application that helps you to track your attendance, view statistics, and much more! <a href="https://skip.dwarsoft.com/"><strong>SKip</strong></a> has been developed keeping in mind the variations of academic criteria of various schools and colleges. To do so, we have conducted a wide range survey involving students from various geographical locations. <strong>SKip — The Attendance Manager </strong>app thus helps you to track your progress with ease and bunk classes easily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8E6GNcVRvprfyiqf7ORvKA.png" /><figcaption>SKip: Attendance Manager Features</figcaption></figure><p>Using SKip is a very easy and painless process. A student can set the minimum attendance percentage which they would like to maintain. Based on the course, the subjects are then auto-suggested and can easily be added from the dashboard. Then the process becomes quite easy and would require a minute’s time daily to update and track your attendance. The students can log attendance daily or for any past date which then updates their attendance percentage for each subject.</p><p>One of the specialties of SKip is that it <strong>predicts for you the number of classes you can bunk</strong> keeping in mind your minimum percentage criteria. If you have a predefined number of classes, then you can add the number of classes and it will predict based on that. So that you don’t have to attend extra classes and sleep peacefully.</p><p>For ease, SKip displays the data in the dashboard for the respective subjects and the overall data too. Students can view their detailed stats using — “<strong>View Stats</strong>“. The subject’s attendance can also be updated directly by using the Present/Bunked option available for the subject on the dashboard.</p><p>The application is flexible enough. If by chance you make a mistake of marking a subject wrong or extra, you can easily undo it from the Options or by using the <strong>Historical Data</strong> tab. The tab also helps in checking the logged attendance using a calendar view for any given date.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CBiBtz1O_WtsPz4npd3u6g.png" /><figcaption>SKip: Attendance Manager Features</figcaption></figure><p>SKip also helps its users maintain <strong>Multiple Profiles</strong>. By using this, students can keep track of their Friend’s Attendance or keep different semester’s attendance separately. Thus each profile becomes less crowded and more readable.</p><p>With Instagram, WhatsApp, and numerous other apps giving the users option for Dark Mode, we are no behind in it. SKip comes in with a <strong>Dark Mode</strong> for the users which can be toggled easily from the Settings.</p><p>We also do realize that there are various scenarios in which the person ends up deleting the application or something goes wrong. To tackle that issue, we have a <strong>Backup And Restore</strong> option available for users to backup their data and keep it safe. When backing up, there’s also an option to Email the backup file and keep it safe. The restore process is easy and simple wherein the user just has to browse the file and select it. The Attendance Manager application handles the rest. In the background, we have an automatic backup running every 12 hours so that even if you miss to backup, we are there for you!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OtjLNGHP7yMWMWWHmDiwbw.png" /><figcaption>SKip: Attendance Manager Features</figcaption></figure><p>We know that students would want to keep their certificates, OD letters, Medical certificates for a long time and there’s an option to do it easily. So, store those documents and it will be available for you to view it later on.</p><p>From our survey, we also understood that some colleges divide the attendance into multiple slots. Students are then required to meet the minimum attendance criteria for each slot too. Thus in SKip, we have added the option to maintain slots and split the attendance into multiple slots.</p><p>Sometimes students get too busy and they might forget to log their attendance. In that case, we have a reminder system too. The students can set the frequency and SKip would alert them to log the attendance. Thus you never miss logging attendance and then getting lost of your record.</p><p>To make it much easier, the students can create a time table for each day and add subjects for the day. It also makes the logging process incredibly easy and convenient. Thus, it would take less than 10 seconds to mark the attendance for the day which makes the application very convenient and easy to use.</p><p>And last but not the least, do not worry about any memory issues. We do know and understand that most of the students use low-end smartphones and they end up having little to no space on their device. So don’t worry! SKip application takes a mere 4 MB of your device’s memory only!!</p><h3><strong>Attendance Manager Features Summarized –</strong></h3><ul><li>Easy and super smooth UI.</li><li>Track attendance easily.</li><li>Important Statistics about attendance.</li><li>Prediction on the number of classes to bunk.</li><li>Dark Theme to ease for the night warriors.</li><li>Multiple Profiles to track multiple friends’ attendance.</li><li>Reminders so that you never miss to update.</li><li>Historical View to view attendance day wise.</li><li>Time Table View so that attendance can be logged easily.</li><li>Documents storage for letters and certificates.</li><li>Maintain slots so that attendance can be maintained for each slot.</li></ul><p>We are not stopping here. This is just the initial release of SKip. We will respond positively to students and people’s responses and suggestions, to make SKip more useable and easy.</p><p>And also note that Skip is <strong>ABSOLUTELY FREE and WITHOUT ADS!!</strong> So what are you waiting for? Join us by trying out the Attendance Manager app! Come use <strong>SKip</strong> and let us<strong> Skip &amp; Kip!</strong></p><p>SKip is available on the Play Store. <a href="https://play.google.com/store/apps/details?id=com.dwarsoftgames.bunkmanager">Click here</a> to download the app now! We would love your review and suggestions :).</p><p>If you like SKip then please do upvote us on <a href="https://www.producthunt.com/posts/skip-attendance-manager"><strong>Product Hunt</strong></a><strong>.</strong></p><p>In the Engineering side, we have a few articles written on how we added unique features and tried improving the User Experience. Do have a read if you would like to learn and implement them -</p><ul><li><a href="https://medium.com/dwarsoft/ditch-the-storage-permission-and-still-provide-media-features-in-an-android-application-caf8b855414a">Ditching the Storage Permission and still providing media-related features.</a></li><li><a href="https://medium.com/dwarsoft/how-to-provide-backup-restore-feature-for-room-database-in-android-d87f111d9c64">Backup &amp; Restore feature for Room Database.</a></li></ul><p>For more, do follow <a href="https://medium.com/dwarsoft">Dwarsoft</a> publications to read more about the interesting things we do from the tech perspective.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d439a5e8247b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dwarsoft/skip-attendance-manager-application-d439a5e8247b">SKip — Attendance Cum Bunk Manager Application</a> was originally published in <a href="https://medium.com/dwarsoft">Dwarsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Implement & Test In-App Update Feature]]></title>
            <link>https://medium.com/dwarsoft/how-to-implement-test-in-app-update-feature-968eb0029f47?source=rss----63fb4749c25d---4</link>
            <guid isPermaLink="false">https://medium.com/p/968eb0029f47</guid>
            <category><![CDATA[dwarsoft-mobile]]></category>
            <category><![CDATA[in-app-update]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Varun Dwarkani]]></dc:creator>
            <pubDate>Sat, 25 Jul 2020 19:29:29 GMT</pubDate>
            <atom:updated>2020-03-11T17:50:12.179Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9yAYAHRJxMtCy5ATSCQSMw.jpeg" /><figcaption>InAppUpdate API by Google to update the app</figcaption></figure><p>I have been fascinated with the new In-App Update API provided by Google as it helps me to ask my users to update the app easily. Previously, I had to work around a lot of things like creating proper dialogs or showing an appropriate card to the users and ask them to update the app from play store where many users complained that they did not get the update option (due to cache issues) or they were getting errors while trying to update the app.</p><p>But now, with the In-App Update API, the work has been less tiresome and easier. While the feature is easy enough to integrate, many developers find difficulty in testing it and making sure that it does not break. Below you will find code samples that will help you to implement the In-App update and test it within minutes.</p><p>In-App Update basically works on the principle — It checks if there is any higher VERSION of the app available on the play store by checking the VERSION CODE of the build. So for the In-App update to detect if there is an update available, make sure you keep the version code higher than the previous version.</p><p>Also, there are two different In-App update mode — Flexible &amp; Immediate. Flexible downloads the update in the background which allows the users to use the app while the update is getting downloaded whereas Immediate blocks any action which can be performed on the application and the users have to wait till the update gets downloaded. By reading this, it is clear enough that Flexible update might provide a very good User Experience but in some cases, we would have to go with Immediate update too. Both the mode will require the users to restart the app to update the app after it is downloaded.</p><p>Let’s dive into the code —</p><ol><li>For the InApp Update feature, we would have to include the PlayCore dependency in our app —</li></ol><pre>//Play Core (For In-App Update API) implementation ‘com.google.android.play:core:1.6.5’</pre><p>2. Now, we would declare some variables and initialize them that we will be using —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35a63b8dd438412dd8304808e9fec0e8/href">https://medium.com/media/35a63b8dd438412dd8304808e9fec0e8/href</a></iframe><p>3. It might happen that an update was getting downloaded and was completed but the user closed the app beforehand thus we were not notified to restart or apply the changes. We can do so by using the InstallStateUpdatedListener(). In the initialization, we will check for DOWNLOADED update —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46eecc4bce51da947d31ccd740909a2b/href">https://medium.com/media/46eecc4bce51da947d31ccd740909a2b/href</a></iframe><p>4. Now ideally have a check which will check for if the latest version is available and has been released. To do so, you can use Firebase RemoteConfig or a simple API call to your backend. Once done, we will create a task and attach the corresponding listeners —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8054d0ba3fc408872e3a278a78d6855/href">https://medium.com/media/d8054d0ba3fc408872e3a278a78d6855/href</a></iframe><p>5. We can write the startInAppUpdate() function as —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/345f994e6fb8f214bb8471e4afea2581/href">https://medium.com/media/345f994e6fb8f214bb8471e4afea2581/href</a></iframe><p>6. Now, we will set a listener for the In-App Update which we started —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0943e96a1cdd8a9ec537949c95ad5ddc/href">https://medium.com/media/0943e96a1cdd8a9ec537949c95ad5ddc/href</a></iframe><p>7. Once done, we will show a popup to the user and ask them to restart the app —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c264d45aaf81c636fe903530f817a6c/href">https://medium.com/media/2c264d45aaf81c636fe903530f817a6c/href</a></iframe><p>Congratulations! We have successfully implemented the InApp flow. But we do have to test it right?!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*ZSMFKoplS4H4D4O6PADSUg.png" /><figcaption>Source — Android Developers</figcaption></figure><p>For testing, there are a few steps that will help you test the new feature easily —</p><ol><li>We will be using the Internal App Sharing feature of Google Play to test our app. For that, first set it up by following the instructions <a href="https://support.google.com/googleplay/android-developer/answer/9303479?hl=en">here</a>. Opt-in for App Signing.</li><li>Build an <strong>AAB </strong>or <strong>APK </strong>and upload it to the <a href="https://play.google.com/apps/publish/internalappsharing/">Internal App Sharing</a>.</li><li>Use the link provided and download the app onto your device.</li><li>Now, increase the VERSION CODE for the next build, generate and share it again on the internal App Sharing as mentioned in Step 2.</li><li>Once done, open the new link in your device and you will see an <strong>UPDATE </strong>button on the Play Store listing page. Do not update the app from there.</li><li>Open the application and you will see the popup we wrote asking the users to update the app. Click on Update and you will see the InApp flow which will begin and download and install the newer update onto your device. (For testing, try calling the startInAppUpdate() directly with true or false to facilitate Flexible or Immediate update and verify the flow.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*nBbBDKQro5ga2R5Cn8tjCg.png" /><figcaption>Source — Android Developers</figcaption></figure><p>We are done. This API by Google is too easy to implement and takes the work off the developer in trying to get the user onto the new version seamlessly. Let&#39;s hope Google keeps bringing in new APIs which will make it easier and more seamless for the users to use the app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=968eb0029f47" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dwarsoft/how-to-implement-test-in-app-update-feature-968eb0029f47">How To Implement &amp; Test In-App Update Feature</a> was originally published in <a href="https://medium.com/dwarsoft">Dwarsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Add Localization Support In Android Apps?]]></title>
            <link>https://medium.com/dwarsoft/how-to-add-localization-support-in-android-apps-bb84bfb54d1f?source=rss----63fb4749c25d---4</link>
            <guid isPermaLink="false">https://medium.com/p/bb84bfb54d1f</guid>
            <category><![CDATA[dwarsoft-mobile]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[localization]]></category>
            <dc:creator><![CDATA[Varun Dwarkani]]></dc:creator>
            <pubDate>Sat, 25 Jul 2020 19:29:12 GMT</pubDate>
            <atom:updated>2019-10-18T18:31:21.097Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*3b8G1ZGFKLU8Np7ZUgFj3g.jpeg" /></figure><p>When we develop an Android App, our main target is to make it accessible to a larger userbase. Initially, we put up all our strings and descriptions in English but not all our users can read the language and understand it.</p><p><strong>A fun fact — </strong>An Indian app called <strong>ShareChat</strong> launched its application only in the local languages excluding English but were able to get more than <strong>100M+ downloads</strong> in less than a year.</p><p>There are so many languages to reach out and it is all done through common practice. Once the base is set up, it becomes very easy to change the languages dynamically as per the user needs.</p><h3><strong>Steps To Add Localization —</strong></h3><ol><li>Put up all the strings used in XML or Java inside strings.xml. In doing so, it is very easy.</li></ol><p>In <strong>res-&gt;values-&gt;strings.xml</strong></p><p>Add a string for “Hello” as</p><pre>&lt;<strong>string name=&quot;hello&quot;</strong>&gt;Hello&lt;/<strong>string</strong>&gt;</pre><p>For using it in XML files, you can use it as</p><pre><strong>=&quot;@string/hello&quot;</strong></pre><p>For using it in java,</p><pre><strong>getString(R.string.<em>hello</em>)</strong></pre><p>2. Now, we will add another language to our application. I will add the Hindi language. For doing so, we will have to find the language code. You can find the reference for language code at — <a href="https://web.archive.org/web/20120814113314/http://colincooper.net/blog/2011/02/17/android-supported-language-and-locales/">https://web.archive.org/web/20120814113314/http://colincooper.net/blog/2011/02/17/android-supported-language-and-locales/</a></p><p>For Hindi, the language code is <strong>“hi”.</strong></p><p>We will create a new strings.xml file. Right-click on<strong> res-&gt;values </strong>and select <strong>New-&gt;Value Resource File.</strong></p><p>Enter the File Name — <strong>strings</strong></p><p>In Directory Name enter — <strong>values-hi</strong> and press OK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*DLwD1qqcosxV3U9Lt7znMA.png" /></figure><p>You will see that the strings turn into a folder and now has 2 files in it. One will be <strong>strings.xml </strong>and the other will be <strong>strings.xml(hi)</strong>.</p><p>3. Now in the <strong>strings.xml(hi), </strong>we will add our new string.</p><pre>&lt;resources&gt;<br>    &lt;<strong>string name=&quot;hello&quot;</strong>&gt;नमस्ते&lt;/<strong>string</strong>&gt;<br>&lt;resources&gt;</pre><p>Ta-Da! We are nearly done. We just have to let the user change the language.</p><p>4. In the MainActivity.java or wherever you want your user to change the language, we will throw a dialog and ask them which they prefer. Here, the code is written to change the language from either,</p><p><strong>a. English to Hindi</strong></p><p><strong>b. Hindi to English</strong></p><p>Here, we will define two functions —</p><p><strong>a.</strong> <strong>changeLanguageDialog() — </strong>Function will help us to display an AlertDialog for the users to confirm if they want to change the language.</p><pre><strong>private void changeLanguageDialog() {<br></strong>    new AlertDialog.Builder(MainActivity.this)<br>            .setTitle(getString(<strong>R.string.<em>language_header</em></strong>))<br>            .setMessage(getString(<strong>R.string.<em>language_description</em></strong>))<br>            .setCancelable(<strong>false</strong>)<br>            .setPositiveButton(getString(<strong>R.string.<em>yes</em></strong>), new DialogInterface.OnClickListener() {<br>                @Override<br>                public void<strong> </strong>onClick(DialogInterface dialog, int which) {<br>                    setLocale();<br>                }<br>            })<br>            .setNegativeButton(<strong>getString(R.string.<em>cancel</em></strong>), <strong>null)</strong><br>            .show();<br>}</pre><p><strong>b. setLocale() — </strong>Function will help us to change the language and reload the activity.</p><pre><strong>public void setLocale() {<br></strong>    Locale locale;<br>    int language_type = sharedPreferences.getInt(<strong>&quot;language_type&quot;</strong>, 1);<br>    <strong>if </strong>(language_type == 1) {<br>        locale = new Locale(<strong>&quot;hi&quot;</strong>);<br>        sharedPreferences.edit().putInt(<strong>&quot;language_type&quot;</strong>, 0).apply();<br>    } <strong>else </strong>{<br>        locale = new Locale(<strong>&quot;en&quot;</strong>);<br>        sharedPreferences.edit().putInt(<strong>&quot;language_type&quot;</strong>, 1).apply();<br>    }<br><br>    Locale.<em>setDefault</em>(locale);<br>    Configuration config = new Configuration();<br>    config.locale = locale;<br>    getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());</pre><pre>    //restart Activity<br>    finish();<br>    startActivity(getIntent());<br><br>}</pre><p><strong>Explanation — </strong>Here, we have an integer value stored in <strong>“language_type”. </strong>This helps us to determine which language to change to. Once decided, we use the Locale to change the language and update the configuration. After doing this, the important step is to <strong>Reload the Activity.</strong></p><p>A common mistake here is that if there are any activities present in the stack, the language will not be updated for them. Those activities will continue to show the previous language. To eliminate that, we can launch the activity using the flags,</p><pre>intent.addFlags(<strong>Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP</strong>);</pre><p>This will clear the stack and keep the activity on top and hence any activity opened after this will have the changed language strings.</p><p>Also, sometimes we would want to prevent some strings from being translated. Let&#39;s say, we want to keep the app name in English alone. For doing so, in the <strong>strings.xml, </strong>we will add the string as —</p><pre>&lt;<strong>string name=&quot;app_name&quot; translatable=&quot;false&quot;</strong>&gt;Sample App&lt;/<strong>string</strong>&gt;</pre><p><strong>Note — </strong>Every time<strong> </strong>the app is opened, the Locale has to be set manually. For this, a sharedPreference integer can be used to check the set value and update the locale.</p><p><strong>Congratulations! </strong>We have successfully added localization within our application. Extending the localization to other languages is very easy as we just need to add another strings.xml for the language code and let the user access it through a menu. Once you put up all the strings in strings.xml, the work becomes very easy.</p><p>If you are planning to publish <strong>Android App Bundle </strong>with localization, this article might be helpful for you to avoid common mistakes — <a href="https://medium.com/@varundwarkani10/how-to-provide-languages-dynamically-using-app-bundle-567d2ec32be6">https://medium.com/@varundwarkani10/how-to-provide-languages-dynamically-using-app-bundle-567d2ec32be6</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb84bfb54d1f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dwarsoft/how-to-add-localization-support-in-android-apps-bb84bfb54d1f">How To Add Localization Support In Android Apps?</a> was originally published in <a href="https://medium.com/dwarsoft">Dwarsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Send Interactive And Easy Update Notifications]]></title>
            <link>https://medium.com/dwarsoft/how-to-send-interactive-and-easy-update-notifications-a01278a0894c?source=rss----63fb4749c25d---4</link>
            <guid isPermaLink="false">https://medium.com/p/a01278a0894c</guid>
            <category><![CDATA[dwarsoft-mobile]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[cloud-messaging]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Varun Dwarkani]]></dc:creator>
            <pubDate>Sat, 25 Jul 2020 19:28:53 GMT</pubDate>
            <atom:updated>2019-10-11T18:28:11.274Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*PladiY3yju2ohMGCELh4mA.png" /></figure><p>We all want our users to stay on the latest app we release with all the bug fixes and feature enhancements. Unfortunately, not all users keep their Wi-Fi on and most of them do not have the auto-update feature of Playstore turned on. Normally, we try to put up a dismissable alert dialog asking politely to update the app but it might not go well. We would want the old users to update in a seamless way and what better than using the notification feature for it. At the same time, we do want to send the notification to the users who are using the latest version too.</p><p>How to get it done? Follow the below steps to get it done within minutes.</p><ol><li>Setup the Firebase Project and link it with the Android app.</li><li>Add the Firebase Cloud Messaging Dependency —</li></ol><pre>implementation &#39;com.google.firebase:firebase-messaging:20.0.0&#39;</pre><p>3. Now, we will parse the notification a bit differently than letting Firebase handle it on its own. For doing so, in <strong>AndroidManifest.xml </strong>add the following code,</p><pre>&lt;<strong>service<br>    android:name=&quot;.utils.FirebaseMessagingService&quot;<br>    android:exported=&quot;false&quot;</strong>&gt;<br>    &lt;<strong>intent-filter</strong>&gt;<br>        &lt;<strong>action android:name=&quot;com.google.firebase.MESSAGING_EVENT&quot; </strong>/&gt;<br>    &lt;/<strong>intent-filter</strong>&gt;<br>&lt;/<strong>service</strong>&gt;</pre><p>For enhanced control, you can also set the notification icon as —</p><pre>&lt;<strong>meta-data<br>   android:name=&quot;com.google.firebase.messaging.default_notification_icon&quot;<br>    android:resource=&quot;@drawable/notification_logo&quot; </strong>/&gt;<br>&lt;<strong>meta-data<br>    android:name=&quot;com.google.firebase.messaging.default_notification_color&quot;<br>    android:resource=&quot;@color/notif&quot; </strong>/&gt;</pre><p>4. Create a Java class named — <strong>FirebaseMessagingService.java.</strong></p><p>5. Use the following code in <strong>FirebaseMessagingService.java</strong></p><pre><strong>public class </strong>FirebaseMessagingService <strong>extends </strong>com.google.firebase.messaging.FirebaseMessagingService {<br><br>    @Override<br>    <strong>public void </strong>onMessageReceived(RemoteMessage remoteMessage) {<br><br>        <strong>if </strong>(remoteMessage.getData().size() &gt; 0) {</pre><pre><strong>int </strong>updateApp = Integer.<em>parseInt</em>(remoteMessage.getData().get(<strong>&quot;updateApp&quot;</strong>));<br><strong>int </strong>versionCode = Integer.<em>parseInt</em>(remoteMessage.getData().get(<strong>&quot;versionCode&quot;</strong>));<br>String title = remoteMessage.getData().get(<strong>&quot;title&quot;</strong>);<br>String message = remoteMessage.getData().get(<strong>&quot;message&quot;</strong>);</pre><pre><strong>if </strong>(updateApp == 1){<br>                <strong>if </strong>(BuildConfig.<strong><em>VERSION_CODE </em></strong>&lt; versionCode) {<br>                    sendUpdateApp(title, message);<br>                }<br>            }<br>        }<br>    }<br>}</pre><p>Let me explain the code a bit here,</p><p>Firebase Cloud Messaging allows us to send the notification with some custom remote parameters. Initially, we extend the class to FirebaseMessagingService. Using the remote parameters, we can customize the notification behaviour for our users. It is a key-value pair and we will use it to parse some parameters for showing the update notification to our users.</p><pre><strong>if </strong>(remoteMessage.getData().size() &gt; 0) {<br>}</pre><p>The condition is used to verify that the remoteMessage is not empty and it has some data.</p><p>We have used two more parameters here —</p><p>a. <strong>updateApp </strong>— This is a check flag. If it is 1, it means the update notification has to be displayed.</p><p>b. <strong>versionCode </strong>— This is an integer value which depends on the developer. Suppose your app’s version code is 20 and you want all the users below 18 to update, you can specify it in the versionCode and only those users will get the notification.</p><p>c. <strong>Title &amp; Message</strong> — This will be displayed as the Title and Message of the notification.</p><p>6. <strong>sendUpdateApp()</strong> function definition —</p><pre><strong>private void </strong>sendUpdateApp(String title, String body) {<br><br>    Intent sharingIntent = <strong>new </strong>Intent();<br>    sharingIntent.setAction(Intent.<strong><em>ACTION_VIEW</em></strong>);<br>    sharingIntent.setData(Uri.<em>parse</em>(<strong>&quot;market://details?id=&quot;+</strong>getPackageName()));<br><br>    PendingIntent sendIntent = PendingIntent.<em>getActivity</em>(<strong>this</strong>, 0, sharingIntent, PendingIntent.<strong><em>FLAG_ONE_SHOT</em></strong>);<br><br>    NotificationManager notificationManager =<br>            (NotificationManager) getSystemService(Context.<strong><em>NOTIFICATION_SERVICE</em></strong>);<br>    Intent intent = <strong>new </strong>Intent(<strong>this</strong>, Main2Activity.<strong>class</strong>);<br>    intent.addFlags(Intent.<strong><em>FLAG_ACTIVITY_NEW_TASK </em></strong>| Intent.<strong><em>FLAG_ACTIVITY_SINGLE_TOP</em></strong>);<br>    PendingIntent pendingIntent = PendingIntent.<em>getActivity</em>(<strong>this</strong>, 0, intent, PendingIntent.<strong><em>FLAG_ONE_SHOT</em></strong>);<br>    Uri soundUri= RingtoneManager.<em>getDefaultUri</em>(RingtoneManager.<strong><em>TYPE_NOTIFICATION</em></strong>);<br><br>    <strong>if </strong>(android.os.Build.VERSION.<strong><em>SDK_INT </em></strong>&gt;= android.os.Build.VERSION_CODES.<strong><em>O</em></strong>) {<br>        @SuppressLint(<strong>&quot;WrongConstant&quot;</strong>)<br>        NotificationChannel notificationChannel=<strong>new </strong>NotificationChannel(<strong>&quot;channel_id&quot;</strong>,<strong>&quot;channel_name&quot;</strong>,NotificationManager.<strong><em>IMPORTANCE_MAX</em></strong>);<br>        notificationChannel.setDescription(<strong>&quot;channel_name&quot;</strong>);<br>        notificationChannel.setName(<strong>&quot;channel_name&quot;</strong>);<br>        Objects.<em>requireNonNull</em>(notificationManager).createNotificationChannel(notificationChannel);<br>    }<br><br>    NotificationCompat.Builder notificationBuilder;<br>    <strong>if </strong>(android.os.Build.VERSION.<strong><em>SDK_INT </em></strong>&gt;= android.os.Build.VERSION_CODES.<strong><em>N</em></strong>) {<br>        notificationBuilder = <strong>new </strong>NotificationCompat.Builder(<strong>this</strong>,<strong>&quot;channel_id&quot;</strong>)<br>                .setSmallIcon(R.drawable.<strong><em>notification_logo</em></strong>)<br>                .setLargeIcon(BitmapFactory.<em>decodeResource</em>(getResources(), R.drawable.<strong><em>notification_logo</em></strong>))<br>                .setStyle(<strong>new </strong>NotificationCompat.BigTextStyle()<br>                        .bigText(body))<br>                .setContentTitle(title)<br>                .setContentText(body)<br>                .addAction(R.drawable.<strong><em>add_icon</em></strong>,<strong>&quot;Update&quot;</strong>,sendIntent)<br>                .setAutoCancel(<strong>true</strong>)<br>                .setSound(soundUri)<br>                .setContentIntent(pendingIntent)<br>                .setDefaults(Notification.<strong><em>DEFAULT_ALL</em></strong>)<br>                .setPriority(NotificationManager.<strong><em>IMPORTANCE_MAX</em></strong>)<br>                .setOnlyAlertOnce(<strong>true</strong>)<br>                .setChannelId(<strong>&quot;channel_id&quot;</strong>)<br>                .setColor(<em>ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)</em>);<br>    }<br>    <strong>else<br>    </strong>{<br>        notificationBuilder = <strong>new </strong>NotificationCompat.Builder(<strong>this</strong>,<strong>&quot;channel_id&quot;</strong>)<br>                .setSmallIcon(R.drawable.<strong><em>notification_logo</em></strong>)<br>                .setLargeIcon(BitmapFactory.<em>decodeResource</em>(getResources(), R.drawable.<strong><em>notification_logo</em></strong>))<br>                .setStyle(<strong>new </strong>NotificationCompat.BigTextStyle()<br>                        .bigText(body))<br>                .setContentTitle(title)<br>                .setContentText(body)<br>                .addAction(R.drawable.<strong><em>add_icon</em></strong>,<strong>&quot;Update&quot;</strong>,sendIntent)<br>                .setAutoCancel(<strong>true</strong>)<br>                .setSound(soundUri)<br>                .setContentIntent(pendingIntent)<br>                .setDefaults(Notification.<strong><em>DEFAULT_ALL</em></strong>)<br>                .setOnlyAlertOnce(<strong>true</strong>)<br>                .setChannelId(<strong>&quot;channel_id&quot;</strong>)<br>                .setColor(<em>ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)</em>);<br>    }<br><em>    </em><strong>if </strong>(notificationManager != <strong>null</strong>) {<br>        <strong>int </strong>id = (<strong>int</strong>) System.<em>currentTimeMillis</em>();<br>        notificationManager.notify(id, notificationBuilder.build());<br>    }<br>}</pre><p>The function will help in generating the notification and display it to the users. Here, we use multiple things — Creating Notification Channel, setting the parameters for the notifications, setting pending intent, dispatching the notification. We have handled the cases for phones below Android Nougat and above it.</p><p><strong>For sending out notifications like this</strong>, you can use <strong>Postman </strong>or any other you like for making an API call/Ajax request —</p><ol><li>Create a <strong>POST/ </strong><a href="https://fcm.googleapis.com/fcm/send"><strong>https://fcm.googleapis.com/fcm/send</strong></a> call request.</li><li>In the Headers, add —</li></ol><blockquote>Content-Type : application/json</blockquote><blockquote>Authorization : key=??</blockquote><p>Key is available at — <strong>Project Overview -&gt; Project Settings -&gt; Cloud Messaging -&gt; Server Key.</strong></p><p>3. Create a raw body request —</p><p>a. For sending to specific tokens —</p><blockquote>{<br>“data”: {<br> “message”: “Please update the app to the latest version for a bug-free and enhanced experience.”,<br> “title”: “New Update Available!”,<br> “updateApp”:1,<br> “versionCode”:18<br> },<br> “to” : “fvOiq81ZeSk:APA91bGtiuoVTjwQ4dAupSUJvZeOBzuiDfTiRgFzMvg_-xdBSdINCQTRL-W-89LBAVhMkHnoPQ8TFg14b3vmQqrGq6BhcV1qjibV-UmrBTyaIJNsss1gRrHkxUwH4qFqiA46JujsL11j”,<br> “priority”: “high”<br>}</blockquote><p>b. Send to a topic —</p><blockquote>{<br> “condition”: “‘all’ in topics”,<br>“data”: {<br> “message”: “Please update the app to the latest version for a bug-free and enhanced experience.”,<br> “title”: “New Update Available!”,<br> “updateApp”:1,<br> “versionCode”:18<br> },<br> “priority”: “high”<br>}</blockquote><p>Make sure you subscribe your users to a specific topic, generally you can subscribe them to topics ‘all’ for such notifications. This can be done as —</p><pre>FirebaseMessaging.<em>getInstance</em>().subscribeToTopic(<strong>&quot;all&quot;</strong>);</pre><p>Or generate the token as,</p><pre><em>FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener&lt;InstanceIdResult&gt;() {<br>    @Override<br>    public void onSuccess(InstanceIdResult instanceIdResult) {<br>        String newToken = instanceIdResult.getToken();<br>        Log.d(&quot;TAG&quot;, newToken);<br>    }<br>});</em></pre><p>Once done, it will look like this,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yY4OWKexvhNxDU6of96P2A.jpeg" /></figure><p>I implemented this feature in <strong>One News</strong> app. One News provides short and crisp news in 60 words. Try it out here — <a href="http://bit.ly/2YPqmeF"><strong>http://bit.ly/2YPqmeF</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a01278a0894c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dwarsoft/how-to-send-interactive-and-easy-update-notifications-a01278a0894c">How To Send Interactive And Easy Update Notifications</a> was originally published in <a href="https://medium.com/dwarsoft">Dwarsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>