<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sushant Kumar on Medium]]></title>
        <description><![CDATA[Stories by Sushant Kumar on Medium]]></description>
        <link>https://medium.com/@baldraider?source=rss-3fa81deff37------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*r1qxy0hj3LInlCQMUE9uKA.jpeg</url>
            <title>Stories by Sushant Kumar on Medium</title>
            <link>https://medium.com/@baldraider?source=rss-3fa81deff37------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 18:06:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@baldraider/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Start an Activity with ADB]]></title>
            <link>https://medium.com/@baldraider/start-an-activity-with-adb-9f8edbe5d652?source=rss-3fa81deff37------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f8edbe5d652</guid>
            <category><![CDATA[adb]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sushant Kumar]]></dc:creator>
            <pubDate>Wed, 08 Jul 2020 12:40:23 GMT</pubDate>
            <atom:updated>2020-07-08T12:40:23.380Z</atom:updated>
            <content:encoded><![CDATA[<p>While working on an application, sometime happens like you have to work on some screens using Activity components but that screen has no entry point during your feature development. How do you open that screen during testing and debugging?</p><p>The first thing comes to mind to make that component MAIN and Default to open that screen on the starting of the application, but it has a headache of removing it. Another way you try to add a fake entry point to open that screen but it also caused problems if you forgot to remove that or if the code is too complex.</p><p>With ADB (Android Debug Bridge) you can perform several tasks on a connected device (or emulator). And you can start an activity from the command line to test that particular component.</p><p>You can use the <strong>start</strong> command from Activity Manager (am) a.k.a the <strong>ADB shell am start -n</strong> command (via ADB) specifying the app package name and the component name as defined in the manifest.</p><pre>adb shell am start -n com.example.demo/.FeatureActivity</pre><p>If the screen within a module, you can specify the app package name and the full component name as defined in the module manifest itself to open.</p><pre>adb shell am start -n com.example.demo/com.example.featuremodule.FeatureActivity</pre><p>You can add other parameters like ACTION (-a android.intent.action.MAIN) and CATEGORY (-c android.intent.category.LAUNCHER).</p><p>You can also send data to that intent , see documentation <a href="https://developer.android.com/studio/command-line/adb#IntentSpec">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f8edbe5d652" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intro To Rx: Part 1]]></title>
            <link>https://medium.com/@baldraider/intro-to-rx-part-1-9ea9cb231c47?source=rss-3fa81deff37------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ea9cb231c47</guid>
            <category><![CDATA[fundamentals]]></category>
            <category><![CDATA[rxjava]]></category>
            <dc:creator><![CDATA[Sushant Kumar]]></dc:creator>
            <pubDate>Mon, 08 Apr 2019 12:27:02 GMT</pubDate>
            <atom:updated>2019-04-08T12:27:02.362Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gxnVmjR1CB2U37EdURLLMw.png" /></figure><p>Users want real-time data, as a developer, you demand fire-and-forget events. You don’t want to be blocked waiting for a result. You want to have the result pushed to you when it is ready. Even better, when working with result sets, you want to receive individual results as they are ready. You do not want to wait for the entire set to be processed before you see the first row. The world has moved to push; users are waiting for us to catch up. Developers have tools to push data, this is easy. Developers need tools to react to push data.</p><p>Welcome to <a href="http://reactivex.io/">Reactive Extensions</a>, Rx is a powerfully productive development tool. Rx enables developers to solve problems in an elegant, familiar and declarative style; often crucially with less code than was possible without Rx. Rx is also very well suited for introducing and managing concurrency for the purpose of <em>offloading</em>. That is, performing a given set of work concurrently to free up the current thread. A very popular use of this is maintaining a responsive UI.</p><h3>Key Types</h3><p>There are two key types to understand when working with Rx, and a subset of auxiliary types that will help you to learn Rx more effectively. The <em>Observer&lt;T&gt;</em> and <em>Observable&lt;T&gt;</em> form the fundamental building blocks for Rx, while implementations of <em>Subject&lt;TSource, TResult&gt;</em> reduce the learning curve for developers new to Rx. Essentially Rx is built upon the foundations of the <a href="http://en.wikipedia.org/wiki/Observer_pattern">Observer</a> pattern.</p><p><strong>Observable&lt;T&gt;<br></strong><em>Observable&lt;T&gt;</em> is one of the two core interfaces for working with Rx. It is a simple interface with just a Subscribe method. You should be able to think of anything that implements <em>Observable&lt;T&gt;</em> as a streaming sequence of <em>T</em> objects. So if a method returned an <em>Observable&lt;Chocolate&gt;</em> I could think of it as a stream of Chocolates. Wowww.</p><pre>interface Observable&lt;T&gt; {<br>    fun subscribe(observer: Observer&lt;T&gt;): Disposable<br>}</pre><p><strong>Observer&lt;T&gt;<br></strong>Observer&lt;T&gt; is the other one of the two core interfaces for working with Rx. It is a simple interface with three methods o<em>nNext(T)</em>, o<em>nError(Throwable)</em> and o<em>nComplete().</em></p><pre>interface Observer&lt;T&gt; {<br>    fun onComplete()<br>    fun onNext(value : T)<br>    fun onError(throwable: Throwable)<br>}</pre><p>An implementation of <em>Observer&lt;T&gt;</em> may have zero or more calls to o<em>nNext(T)</em> followed optionally by a call to either o<em>nError(Throwable)</em> or o<em>nComplete()</em>. This protocol ensures that if a sequence terminates, it is always terminated by a o<em>nError(Throwable)</em>, <strong>or</strong> an o<em>nComplete()</em>. This protocol does not, however, demand that an o<em>nNext(T)</em>, o<em>nError(Throwable)</em> or o<em>nComplete()</em> ever be called. This enables the concept of empty and infinite sequences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Qmb0XImNvVoB2CIfdEKC5A.jpeg" /><figcaption>Time to code</figcaption></figure><h4>Implementing Observer&lt;T&gt; and Observable&lt;T&gt;</h4><p>Let do some code to better understand</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b0111048b1bdfb47c160e4208aed1f5/href">https://medium.com/media/3b0111048b1bdfb47c160e4208aed1f5/href</a></iframe><pre>The output of the above code like <br>Received value a<br>Received value b<br>Received value c<br>Sequences stream completed</pre><p><strong>Subject&lt;T&gt;<br></strong>If you were to create your own implementation of <em>Observable&lt;T&gt;</em> you may find that while you want to publicly expose the Observable characteristics you still need to be able to publish items to the subscribers, throw errors and notify when the sequence is complete. Why that sounds just like the methods defined in <em>Observer&lt;T&gt;</em>! While it may seem odd to have one type implementing both interfaces, it does make life easy. This is what <a href="http://reactivex.io/documentation/subject.html">subjects</a> can do for you. <a href="http://reactivex.io/documentation/subject.html"><em>Subject&lt;T&gt;</em></a> is the most basic of the subjects. Effectively you can expose your <em>Subject&lt;T&gt;</em> behind a method that returns <em>Observable&lt;T&gt;</em> but internally you can use the o<em>nNext</em>, o<em>nError</em> and o<em>nComplete</em> methods to control the sequence.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95dc5f9312d346a4d8e4e156b9cadb8d/href">https://medium.com/media/95dc5f9312d346a4d8e4e156b9cadb8d/href</a></iframe><p>The above code output the same as we see the previous example.<br>There are three siblings to <em>Subject&lt;T&gt;</em> that offer subtly different implementations which can drastically change the way your program runs.</p><p><strong>RelaySubject&lt;T&gt;<br></strong>Provides the feature of caching values and then replaying them for any late subscriptions. Consider this example</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3579d3a1b415fada69c2c60d478b613c/href">https://medium.com/media/3579d3a1b415fada69c2c60d478b613c/href</a></iframe><pre>Output Log :<br>Received Value b<br>Received Value c<br>Sequences stream completed</pre><p>As you can see that ‘b’ and ‘c’ would be written to the console, but ‘a’ ignored. If we were to make the minor change to make the subject a <em>ReplaySubject&lt;T&gt;</em> we would see all publications again.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5d5415f4f86dd338b146d428c40acab/href">https://medium.com/media/a5d5415f4f86dd338b146d428c40acab/href</a></iframe><pre>Output Log<br>Received Value a<br>Received Value b<br>Received Value c<br>Sequences stream completed</pre><p>This can be very handy for eliminating race conditions. Be warned though, the default constructor of the <em>ReplaySubject&lt;T&gt;</em> will create an instance that caches every value published to it. In many scenarios, this could create unnecessary memory pressure on the application. <em>ReplaySubject&lt;T&gt;</em> allows you to specify simple cache expiry settings that can alleviate this memory issue. One option is that you can specify the size of the buffer in the cache. In this example, we create the <em>ReplaySubject&lt;T&gt;</em> with a buffer size of 2, and so only get the last two values published prior to our subscription:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff66218ad9c627671cc0a5f00231973e/href">https://medium.com/media/ff66218ad9c627671cc0a5f00231973e/href</a></iframe><p>Here the output would show that the value ‘a’ had been dropped from the cache, but values ‘b’ and ‘c’ were still valid. The value‘d’ was published after we subscribed so it is also written to the console.</p><pre>Output Log<br>Received Value b<br>Received Value c<br>Received Value d<br>Sequences stream completed</pre><p>Another option for preventing the endless caching of values by the <em>ReplaySubject&lt;T&gt;</em> is to provide a window for the cache. In this example, instead of creating a <em>ReplaySubject&lt;T&gt;</em> with buffer size, we specify a window of time that the cached values are valid for.</p><p><strong>BehaviourSubject&lt;T&gt;<br></strong>is similar to <em>ReplaySubject&lt;T&gt;</em> except it only remembers the last publication. <em>BehaviorSubject&lt;T&gt;</em> also requires you to provide it a default value of <em>T</em>. This means that all subscribers will receive a value immediately (unless it is already completed).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24b1517ca4f5a546493513f470a5f897/href">https://medium.com/media/24b1517ca4f5a546493513f470a5f897/href</a></iframe><p>Note that there is a difference between a <em>ReplaySubject&lt;T&gt;</em> with a buffer size of one (commonly called a ‘replay one subject’) and a <em>BehaviorSubject&lt;T&gt;</em>. A <em>BehaviorSubject&lt;T&gt;</em> requires an initial value. With the assumption that neither subjects have completed, then you can be sure that the <em>BehaviorSubject&lt;T&gt;</em> will have a value. You cannot be certain with the <em>ReplaySubject&lt;T&gt;</em> however. With this in mind, it is unusual to ever complete a <em>BehaviorSubject&lt;T&gt;</em>. Another difference is that a replay-one-subject will still cache its value once it has been completed. So subscribing to a completed <em>BehaviorSubject&lt;T&gt;</em> we can be sure to not receive any values, but with a <em>ReplaySubject&lt;T&gt;</em> it is possible.</p><p><strong>AysncSubject&lt;T&gt;</strong></p><p>AsyncSubject&lt;T&gt; is similar to the Replay and Behavior subjects in the way that it caches values, however, it will only store the last value, and only publish it when the sequence is completed. The general usage of the <em>AsyncSubject&lt;T&gt;</em> is to only ever publish one value then immediately complete. This means that is becoming quite comparable to <em>Task&lt;T&gt;</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6d7ecbcdfb9a7d9259c14cb4c09662e/href">https://medium.com/media/d6d7ecbcdfb9a7d9259c14cb4c09662e/href</a></iframe><p>Thanks for reading folks, let me know if I have done anything wrong. Also, make claps if you like.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ea9cb231c47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Linking Story onAndroid]]></title>
            <link>https://medium.com/@baldraider/deep-linking-story-onandroid-5b4019218284?source=rss-3fa81deff37------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b4019218284</guid>
            <category><![CDATA[deep-links-android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Sushant Kumar]]></dc:creator>
            <pubDate>Mon, 08 Apr 2019 12:01:48 GMT</pubDate>
            <atom:updated>2019-04-08T12:04:08.029Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_EMAdb3J6LeMtlrHa5gBIg.jpeg" /></figure><h3>What is Deep linking?</h3><p>Deeplinks are a concept that helps users navigate between <strong>the web</strong> and <strong>applications. </strong>They are basically URLs which navigate users directly to the specific content in <strong>applications.</strong></p><h3>What is Android App Links</h3><p>On the other hand<strong>, Android App Links</strong> allow an app to designate itself as the default handler of the application domain or URL. <strong>Unfortunately,</strong> <strong>It works only on Android 6.0 (API level 23) and higher.</strong></p><h3>A Scenario For Deep Links to App Content</h3><p>When a user clicked URL, the Android system tries each of the following actions, in sequential order, until the request succeeds:</p><ol><li>Open the user’s preferred app that can handle the URI, if one is designated.</li><li>Open the only available app that can handle the URI.</li><li>Allow the user to select an app from a dialog.</li></ol><h3>How to define intent filters</h3><p>When we talk about handling how to navigate users directly to specific content in <strong>applications, </strong>we should think about adding<strong> </strong>an intent filter in our manifest file. An intent filter should contain the following elements and attribute values;</p><ol><li>Define <strong>ACTION_VIEW</strong> intent action so that the intent filter can be reached from Google Search.</li></ol><pre>&lt;action android:name=&quot;<strong>android.intent.action.VIEW</strong>&quot; /&gt;</pre><p>2. We should include the <strong>BROWSABLE</strong> category in order to be accessible from a web browser. We should also have <strong>DEFAULT</strong> a category for responding to implicit intents</p><pre>&lt;category android:name=&quot;android.intent.category.<strong>DEFAULT</strong>&quot; /&gt;<br>&lt;category android:name=&quot;android.intent.category.<strong>BROWSABLE</strong>&quot; /&gt;</pre><p>3. We should define one or more &lt;data&gt; tags. Each of these tags represents a URI format that resolves to the activity. The following example represents <strong>a simple data tag for dolap.com Android app.</strong></p><pre>&lt;<strong>data</strong><br>    <strong>android:host</strong>=&quot;beebom.com&quot;<br>    <strong>android:scheme</strong>=&quot;https&quot; /&gt;</pre><p>The following XML snippet shows how you might specify an intent filter in your manifest for deep linking:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a63a753a54326cacf28743665782db8b/href">https://medium.com/media/a63a753a54326cacf28743665782db8b/href</a></iframe><p>It might seem as though this supports only https://app.beebom.com/posts;https://app.beebom.com/videos and app://beebom.com/open. As you can see you can also define a different schema for handling different types of URL based on your requirements</p><h3>How to read data from incoming intents</h3><p>When you define your intent filter that can handle specific URLs, <strong>the system can start your activity via that intent filter. </strong>Once the system starts your activity through an intent filter, you can use data provided by the <a href="https://developer.android.com/reference/android/content/Intent.html">Intent</a> to determine what you need to render. Call the <a href="https://developer.android.com/reference/android/content/Intent.html#getData()">getData()</a> and <a href="https://developer.android.com/reference/android/content/Intent.html#getAction()">getAction()</a> methods to retrieve the data and action associated with the incoming <a href="https://developer.android.com/reference/android/content/Intent.html">Intent</a>. You can call these methods at any time during the lifecycle of the activity, but you should generally do so during early callbacks such as <a href="https://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle)">onCreate()</a> or <a href="https://developer.android.com/reference/android/app/Activity.html#onStart()">onStart()</a>.</p><p>Here’s a snippet that shows how to retrieve data from an <a href="https://developer.android.com/reference/android/content/Intent.html">Intent</a>:</p><pre>override fun onCreate(savedInstanceState: Bundle?) {<br>    super.onCreate(savedInstanceState)<br>    setContentView(R.layout.main)<br><br>    val action: String? = intent?.action<br>    val data: Uri? = intent?.data<br>}</pre><h3>Providing proper Back navigation</h3><p>While integrating a deep link in your application you should consider best practices of using a deep link. You can do this in two ways, first, you directly send the user to the main content page that should be open by the link without any pop-up or sign up process(for first time user) and another provides proper back navigation when a user press back button.</p><p>Ordinarily, the system incrementally builds the back stack as the user navigates from one activity to the next. However, when the user enters your app with a <em>deep link</em> that starts the activity in its <strong>own task</strong>, it’s necessary for you to synthesize a new back stack because the <strong>activity is running in a new task without any back stack at all</strong>.</p><p>you can declare the logical parent of the activity by specifying the <a href="https://developer.android.com/guide/topics/manifest/activity-element.html#parent">android:parentActivityName</a> attribute in the <a href="https://developer.android.com/guide/topics/manifest/activity-element.html">&lt;activity&gt;</a> element. This allows the system to facilitate navigation patterns because it can determine the logical <em>Back</em> or <em>Up</em> navigation path with this information.</p><pre>android:parentActivityName=&quot;com.beebom.app.MainActivity&quot; &gt;</pre><p>With the parent activity declared this way, you can use them <a href="https://developer.android.com/reference/android/support/v4/app/NavUtils.html">NavUtils</a> APIs to synthesize a new back stack by identifying which activity is the appropriate parent for each activity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b4019218284" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>