<?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[Adventurous Android - Medium]]></title>
        <description><![CDATA[Everything from Cupcake to Pie! - Medium]]></description>
        <link>https://medium.com/adventurous-android?source=rss----cd32bf3b7535---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Adventurous Android - Medium</title>
            <link>https://medium.com/adventurous-android?source=rss----cd32bf3b7535---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 05:57:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/adventurous-android" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building your first Kotlin Multiplatform app — Getting Started]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/adventurous-android/building-your-first-kotlin-multiplatform-app-getting-started-8ad10d7d4e9f?source=rss----cd32bf3b7535---4"><img src="https://cdn-images-1.medium.com/max/1293/1*8H11dtoJEKkd3kOe_dxQCA.png" width="1293"></a></p><p class="medium-feed-snippet">Start learning Kotlin/Native and how you can share common business logic among apps for multiple platforms. Get started with this article!</p><p class="medium-feed-link"><a href="https://medium.com/adventurous-android/building-your-first-kotlin-multiplatform-app-getting-started-8ad10d7d4e9f?source=rss----cd32bf3b7535---4">Continue reading on Adventurous Android »</a></p></div>]]></description>
            <link>https://medium.com/adventurous-android/building-your-first-kotlin-multiplatform-app-getting-started-8ad10d7d4e9f?source=rss----cd32bf3b7535---4</link>
            <guid isPermaLink="false">https://medium.com/p/8ad10d7d4e9f</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Vivek Chanddru]]></dc:creator>
            <pubDate>Sun, 23 Dec 2018 09:47:11 GMT</pubDate>
            <atom:updated>2019-05-15T19:08:06.026Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[What’s new in Android P — The breaking changes and Amazing features]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/adventurous-android/whats-new-in-android-p-the-breaking-changes-and-amazing-features-8f4e864802a9?source=rss----cd32bf3b7535---4"><img src="https://cdn-images-1.medium.com/max/2600/1*mgjVbMQBmFJSvmE-LbLvFg.png" width="4706"></a></p><p class="medium-feed-snippet">All you need to know about the changes in the upcoming version of Android dessert&#x200A;&#x2014;&#x200A;the Android P. Read to know more.</p><p class="medium-feed-link"><a href="https://medium.com/adventurous-android/whats-new-in-android-p-the-breaking-changes-and-amazing-features-8f4e864802a9?source=rss----cd32bf3b7535---4">Continue reading on Adventurous Android »</a></p></div>]]></description>
            <link>https://medium.com/adventurous-android/whats-new-in-android-p-the-breaking-changes-and-amazing-features-8f4e864802a9?source=rss----cd32bf3b7535---4</link>
            <guid isPermaLink="false">https://medium.com/p/8f4e864802a9</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Vivek Chanddru]]></dc:creator>
            <pubDate>Thu, 08 Mar 2018 17:40:34 GMT</pubDate>
            <atom:updated>2018-03-14T04:40:04.000Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Building your first IOT-Android application with Android Things!]]></title>
            <link>https://medium.com/adventurous-android/building-your-first-iot-android-application-with-android-things-762fdb3d9911?source=rss----cd32bf3b7535---4</link>
            <guid isPermaLink="false">https://medium.com/p/762fdb3d9911</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[android-things]]></category>
            <dc:creator><![CDATA[Ashwin S]]></dc:creator>
            <pubDate>Thu, 22 Feb 2018 09:04:58 GMT</pubDate>
            <atom:updated>2018-02-22T09:04:58.251Z</atom:updated>
            <content:encoded><![CDATA[<p>I was one of those passionate developers who tried out Android Things when the first developer preview was out. Being an attendee of the recently concluded Google Developer Days, I was given a <a href="https://developer.android.com/things/hardware/imx7d-kit.html">Pico Pro Maker kit</a> sans Rainbow Hat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JsdCCeDAyO3BKwnAmdVACA.jpeg" /><figcaption>That Kit ❤</figcaption></figure><p>Well that brought out the enthusiastic kid who tried out Android Things when it was first out. Now with almost 6 developer previews old, let me show you the gateway to the world of IOT through the technology I love the most, Android!</p><p>Alright enough with my blabbles, today I am going to give you a simple road map to get started with the Android Things IOT platform.</p><blockquote><strong>Downloading the OS to be flashed to the kit</strong></blockquote><ol><li>Head up to the <a href="https://partner.android.com/things/console/">Android Things Developer console</a>. Remember you can publish your apps and OTA updates for your hardware device only through this console and not the general Play Console.</li><li>Select ADD A PRODUCT and just specify the name and description for your product.</li><li>Under the FACTORY IMAGES tab, create a build with the latest Android Things version and download the zip from the Build Configuration list.</li></ol><p><strong>Ensure you have the items as in the </strong><a href="https://developer.android.com/things/hardware/imx7d-kit.html"><strong>Pico Pro Maker kit</strong></a><strong> or equivalent assembled before proceeding further !</strong></p><blockquote><strong>Flashing the image onto the board</strong></blockquote><ol><li>Download the Android Things Setup Utility from the <a href="https://partner.android.com/things/console/#/tools">Android Things Console</a>.</li><li>Start the setup utility.</li><li>Select the option to install Android Things and optionally set up Wi-Fi.</li><li>Select <strong>NXP Pico i.MX7D</strong> as the hardware board.</li><li>Specify the location to the zip of your downloaded Android Things OS for flashing the board.</li><li>You will be given the option to set up Wi-Fi after the device is flashed.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*fNfkD_FbIjB7HyqpO_Nnew.jpeg" /></figure><p>You should get that on the display if the flash succeeded.</p><p><strong>Wi-Fi setup might fail on most cases, so you can still configure your Wi-Fi once you boot in to your Android Things OS.</strong></p><p>If you don’t want to use the setup utility or if you face any miscellaneous problems, you can download an image from the <a href="https://developer.android.com/things/console/index.html">Android Things Console</a> and <a href="https://developer.android.com/things/hardware/fastboot.html">manually</a> flash it onto the device.</p><p><strong>But ensure that you have set the path to the Platform Tools of your SDK which contains the Fastboot script or the OS flashing will fail on either cases.</strong></p><pre>export PATH=”path/to/platform-tools”:$PATH</pre><blockquote><strong>Initialising the Android app for your product</strong></blockquote><ol><li>Fill up the application name and package ID as usual.</li><li>Android Studio v3 comes with an option to enable targetting for Android Things. Enable it if you are developing the usual Android application as well as for the Product. Else just enable Android Things and continue to finish the usual steps.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4hkJWH-H5FYPYGTJlN_PsA.png" /></figure><blockquote><strong>Initial Setup</strong></blockquote><ol><li>There would be a pre added dependancy for Android Things. Replace</li></ol><pre>compileOnly &#39;com.google.android.things:androidthings:+</pre><p>with the latest preview (0.6 dev preview at the time of writing)</p><pre>compileOnly &#39;com.google.android.things:androidthings:0.6-devpreview&#39; </pre><p>2. Since we are building for a single product and also the board supports only OEM applications, we are going to directly boot into the application upon launching the Product. So include</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59d03d00d745aca1a44e8a54890892be/href">https://medium.com/media/59d03d00d745aca1a44e8a54890892be/href</a></iframe><p>in your launcher activity in the Manifest. (<em>For debugging and development purposes you can uncomment the above lines of code!</em>)</p><blockquote><strong>Capturing the image using the camera module</strong></blockquote><p>So we are going to capture an image using the camera module and set it as a bitmap to an ImageView.</p><ol><li>Ensure you include the following utils for the <a href="https://gist.github.com/ashwinbhai1994/94df0205a15d744218dfa28362ca248f">Camera Handler</a> and <a href="https://gist.github.com/ashwinbhai1994/9f1f14fea588a64942510cd935c5fd1a">Image Pre processing</a> before proceeding further.</li></ol><p>2. Initialise the Camera Handler and the Image Pre-processor in a background thread as</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8238280d0a27e2b6ede045911e29dfb9/href">https://medium.com/media/8238280d0a27e2b6ede045911e29dfb9/href</a></iframe><p>3. Fire this call in the background whenever you need the image to be captured by the camera module.</p><pre>cameraHandler?.takePicture()</pre><p>This call will take care of creating a capture session</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7d075bd97956e69b529f7c2567d6f72/href">https://medium.com/media/f7d075bd97956e69b529f7c2567d6f72/href</a></iframe><p>and triggering image capture for that active session.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c306698ee3a41189e6d1c799de868305/href">https://medium.com/media/c306698ee3a41189e6d1c799de868305/href</a></iframe><p>4. Ensure that you have implemented the <strong>OnImageAvailableListener</strong> in the calling activity so that the following method absorbs the result from the capture.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1eaf1b795a702271d3f6173b71f34d7/href">https://medium.com/media/a1eaf1b795a702271d3f6173b71f34d7/href</a></iframe><p>That’s it guys and girls 😃, this is how you can kick start your journey building fancy IOT products with Android. The complete project reference for the Image capture is on Github as</p><p><a href="https://github.com/ashwinbhai1994/Android-Things-Demo">ashwinbhai1994/Android-Things-Demo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=762fdb3d9911" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adventurous-android/building-your-first-iot-android-application-with-android-things-762fdb3d9911">Building your first IOT-Android application with Android Things!</a> was originally published in <a href="https://medium.com/adventurous-android">Adventurous Android</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Manage Lifecycle of Rx Observables in DataBinding ViewModels (MVVM)]]></title>
            <link>https://medium.com/adventurous-android/manage-lifecycle-of-rx-observables-in-databinding-viewmodels-mvvm-e4ab3ec956ef?source=rss----cd32bf3b7535---4</link>
            <guid isPermaLink="false">https://medium.com/p/e4ab3ec956ef</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[rxjava]]></category>
            <category><![CDATA[android-mvvm]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-data-binding]]></category>
            <dc:creator><![CDATA[Muthu Raj]]></dc:creator>
            <pubDate>Sun, 18 Feb 2018 19:13:37 GMT</pubDate>
            <atom:updated>2018-02-18T19:13:37.286Z</atom:updated>
            <content:encoded><![CDATA[<p>If you don’t know what databinding is , head over to the <a href="https://developer.android.com/topic/libraries/data-binding/index.html">documentation</a> and read about it.</p><p>Simply, data binding is a glue between your ViewModel and your view. It generates all the boilerplate to get the text from you view model and set in on textView, get the url from viewmodel and call the static method specified to load image and observe on changes on the fields in the view models.</p><p>With data binding, we can import java classes, use java class instances inside xml. Though we can use as many different class instances as we want, it would be better if we only use one instance of class per xml. That class would be the ViewModel of that particular xml.</p><p>My thumb rule is, each xml should contain only one instance<strong> </strong>. It would be handy in several places and I wrote about one in <a href="https://medium.com/@muthuraj57/recyclerview-with-android-data-binding-cc2e5aefd53a">here</a>.</p><p>Now we created one ViewModel per view (or layout file to be exact) and all the logic to show data is in that ViewModel. The data processing and manipulation would not be synchronous in nature. We may want to initiate a network call and wait for it to show some data, get data from local storage which all are asynchronous in nature.</p><p>These kind of operations should be properly cleared when the view is not being used (not shown to the user) for performance reasons and to avoid memory leak. We can use <a href="https://github.com/ReactiveX/RxJava">RxJava</a> for this asynchronous operations (or reactive operations). RxJava needs to be <a href="http://reactivex.io/documentation/operators/subscribe.html">subscribed</a> to start the operations and can be <a href="http://reactivex.io/RxJava/javadoc/io/reactivex/disposables/Disposable.html">disposed</a> to clear the operations.</p><p>Basically, our ViewModels need to be lifecycle aware.</p><p>We create a base class for the ViewModel named <em>BaseViewModel</em> which contains <em>onAttach</em> and <em>onDetach</em> methods from which we can <a href="http://reactivex.io/documentation/operators/subscribe.html">subscribe</a> and <a href="http://reactivex.io/RxJava/javadoc/io/reactivex/disposables/Disposable.html">dispose</a> the observables correspondingly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b7168fd41a5db16999740760ac017a7/href">https://medium.com/media/8b7168fd41a5db16999740760ac017a7/href</a></iframe><p>Now we need to call these methods at the correct time. Another important note is, all the variable names on xml should be same. Quoting from my <a href="https://medium.com/@muthuraj57/recyclerview-with-android-data-binding-cc2e5aefd53a">previous article</a>:</p><blockquote>Usually, we set the variable for the layout using <em>DataBinding.set{{variableName}}(object). </em>There is another less known method in the <a href="https://developer.android.com/reference/android/databinding/ViewDataBinding.html">ViewDataBinding</a> class(which is the base class for all generated data binding class) called <a href="https://developer.android.com/reference/android/databinding/ViewDataBinding.html#setVariable(int,%20java.lang.Object)">setVariable</a> which takes a BR field and the actual variable as parameters. For every data binding variable, a field in BR class is generated(just like for every drawable, layout, strings etc. a field is created in R.java).</blockquote><p>Here we have a generic method to bind viewmodels for any binding with any ViewModel class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/512dc7b063899c1a2f6af86d41f8fc0a/href">https://medium.com/media/512dc7b063899c1a2f6af86d41f8fc0a/href</a></iframe><p>We leverage the <a href="https://developer.android.com/reference/android/view/View.OnAttachStateChangeListener.html">View.OnAttachStateChangeListener</a> to get attach/detach events of that particular view and call the ViewModel’s onAttach/onDetach methods correspondingly.</p><p>Why am I throwing exception if the binding is not success? It was explained in my previous article which I’m quoting here</p><blockquote>The <em>setVariable </em>method returns a boolean which indicates whether the binding is successful or not. Why would it no be successful, you may ask. Usually because the BR field you specified is not the name you set in you xml. If it fails, our ViewModel would not be bind to the view and nothing will show on the UI. It is hard to debug what went wrong at this point, trust me. That’s why we throw an exception if the binding variable is mismatched (<a href="https://en.wikipedia.org/wiki/Fail-fast">Fail Fast</a>).</blockquote><p>Here we manage the lifecycle of views as local as possible(local to that particular view). Now all we have to do is extend the <a href="https://gist.github.com/muthuraj57/941e4730d5e1da4221741e7d73b7534d">BaseViewModel</a>, override <em>onAttach </em>method and start your subscription and add that to the <em>compositeDisposable.</em></p><p>For binding ViewModels, instead of calling set{{vairableName}} method, call</p><pre><em>bindViewModel(viewModelInstance)</em></pre><p>Since it is an <a href="https://kotlinlang.org/docs/reference/extensions.html#extension-functions">extension function</a>, we can call this method directly from the binding object.</p><p>Note: We <a href="http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/disposables/CompositeDisposable.html#clear--">clear</a> the CompositeDisposable instead of <a href="http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/disposables/CompositeDisposable.html#dispose--">dispose</a> because after dispose, we can’t use the compositeDisposable after disposing(See <a href="https://youtu.be/QdmkXL7XikQ?t=1983">Common RxJava Mistakes</a> by Daniel Lew).</p><p>TL;DR</p><ol><li>Paste the <a href="https://gist.github.com/muthuraj57/941e4730d5e1da4221741e7d73b7534d">BaseViewModel.kt</a> and <a href="https://gist.github.com/muthuraj57/fb231c607c169a8c73918180441d0157">DataBindingUtil.kt</a> in your project</li><li>All the xml variable names should be same (ex: viewModel)</li><li>Extend the view model from BaseViewModel</li><li>Subscribe to the observables in <em>onAttach </em>method and add the disposables to <em>compositeDisposable.</em></li><li>To set the viewmodel, call <em>bindViewModel </em>method from the binding with the view model instance as parameter.</li></ol><p>Now your subscriptions are managed automatically. Happy coding :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4ab3ec956ef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adventurous-android/manage-lifecycle-of-rx-observables-in-databinding-viewmodels-mvvm-e4ab3ec956ef">Manage Lifecycle of Rx Observables in DataBinding ViewModels (MVVM)</a> was originally published in <a href="https://medium.com/adventurous-android">Adventurous Android</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WebRTC for Android Guide— Develop video call app easily!]]></title>
            <link>https://medium.com/adventurous-android/getting-started-with-webrtc-part-4-de72b58ab31e?source=rss----cd32bf3b7535---4</link>
            <guid isPermaLink="false">https://medium.com/p/de72b58ab31e</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[webrtc]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vivek Chanddru]]></dc:creator>
            <pubDate>Sun, 04 Feb 2018 17:43:00 GMT</pubDate>
            <atom:updated>2025-05-03T06:56:35.142Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xFyy_8vcIody08eRyXscpQ.png" /></figure><p>WebRTC is the up and coming technology as everyone is jumping towards the voice and video calls. WebRTC has been in the know for a while, but it has always been a pain to implement it in Android. This tutorial was laid out in such a way that it is easy for everyone to follow the development process.</p><p>Google has found out that there are a lot of Android developers trying it hard to get started with WebRTC (maybe this series poked them to realize that? 🤔 They have released the new <a href="https://webrtc.org/native-code/android/">gradle dependencies for WebRTC development</a>. Mind you! these dependencies are for *<strong>development</strong>* purposes only!</p><p>This article will use the latest dependency for WebRTC to develop an end to end Peer-to-Peer video calling application.</p><p>After a really long gap(Sorry for that 😔), I am here with the last part of this series. (Hurray!)</p><p>This is <strong>Part 4 </strong>of the series “<em>Getting started with WebRTC for Android</em>” and if you are new to this article, please make sure that you have read the previous parts of this series before continuing with this part.</p><p><strong>Part 1: </strong><a href="https://vivekc.xyz/getting-started-with-webrtc-for-android-daab1e268ff4"><em>Introduction to WebRTC</em></a></p><p><strong>Part 2: </strong><a href="https://vivekc.xyz/peerconnection-getting-started-with-webrtc-part-2-e426b08d1028"><em>Introduction to PeerConnection</em></a></p><p><strong>Part 3: </strong><a href="https://vivekc.xyz/peer-to-peer-video-calling-webrtc-for-android-4132fd0ac54">Peer-to-Peer Video Calling — Loopback</a></p><p><strong>Part 4:</strong> Peer-to-Peer Video Calling with socket.io (this article)</p><h3>Flashback</h3><p>Remember our guy nerd who wanted to propose to his girl? By the end of last part, he was able to create an app and talk to himself (See <a href="https://vivekc.xyz/peer-to-peer-video-calling-webrtc-for-android-4132fd0ac54">here</a> to know about *loopback* call implementation if you haven’t already). Too bad, talking to himself isn’t going to help him get his love. He wants to achieve something like the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X4iOI4qIKwoC8oK7AFdr6w.jpeg" /></figure><blockquote>Love isn’t simple. So is WebRTC. It is tedious but sweet when you finally get it!</blockquote><p>The actual transfer would actually be something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6wjpiu3i1aoaCWp_6-S4JA.png" /></figure><ul><li>The peers have to login to the signaling server through a certain way. This would help the server in identifying the proper recipient of a call. This is indicated using (1,2,3 and 4)</li><li>Once logged in, our guy creates his offer, stores a copy of it (Local description) and sends it to the server which acts as a courier and delivers it to the rightful lady. (5,6,7 and 8)</li><li>The girl now opens up the offer, stores it to her collection (Remote description), generates the response to the offer (answer), stores it locally and sends it through the same courier to our boy (9–13)</li><li>Our guy now stores the response received from her (14)</li><li>Some negotiation (Ice Candidates negotiation) happens between them(15–20)</li><li>Once connected, they both could talk their hearts out, as long as they want! This could happen either through a direct P2P connection between them or through a TURN server if someone is behind a firewall (More like a giant of a dad!)</li></ul><h3>Ready to Serve</h3><p>To start off, we need a server setup up and running along with TURN and STUN. If you are new, STUN is usually used to find out the public IP of a device and TURN is used as a relay server incase P2P is not possible between the peers. If you want to know more, you could refer the <a href="https://vivekc.xyz/peerconnection-getting-started-with-webrtc-part-2-e426b08d1028">part 2</a> of this series which deals with all the theoretical stuff!</p><p>For this demo, we are going to use the amazing platform given by <a href="https://xirsys.com/">Xirsys</a> for our STUN and TURN needs. I have a free subscription to their website and using their free tier. You might have to opt for a paid subscription or have your own setup if you want to scale it to production.</p><p>We are going to use the Google’s code labs article to set our signalling server. This article is more focused on the Android developer scope and doesn’t do much on the server side. So, we are going to use almost the same server as in the code labs demo.</p><p>Follow the link <a href="https://codelabs.developers.google.com/codelabs/webrtc-web/#6">here</a> to find out how to configure socket.io for local development. You might not want to go production with this server code as it has a lot of security holes in it. (The code there is from socket.io version 1.2 — We are going to use the same version for the sake of demo)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8148580dabb1fbb6d5643872dd263a31/href">https://medium.com/media/8148580dabb1fbb6d5643872dd263a31/href</a></iframe><p>For the complete node server, check out the<a href="https://github.com/vivek1794/webrtc-android-codelab/tree/master/signalling"> GitHub repository.</a></p><h3>The Android Way</h3><p>Coming to the Android part, if you have been following the series so far, you might find this a lot easier. In the previous part, we created the local and remote peers in the same activity class and tried to transfer the audio and video from one peer to another. We got the offer from local peer and set it to the remote peer instance.</p><p>When we are dealing with remote calls, we care just about our own local peer. Instead of managing the remote peer, we send the data needed for connection (SDP and ICE candidates) through the signaling channel.</p><p>Let us take a look at the code for call handling and signaling.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27dd1a190281150e65225abb8678a38e/href">https://medium.com/media/27dd1a190281150e65225abb8678a38e/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2493d1bcf003e17b82bb13112eb721d5/href">https://medium.com/media/2493d1bcf003e17b82bb13112eb721d5/href</a></iframe><p>That’s a lot of code. But if you break it into pieces, and reference it with the code of Part — 2, it would make a lot of sense. The comments should help you out in finding your way through the code. (If you are still into JAVA, check out the Github repository — <a href="https://github.com/vivek1794/webrtc-android-codelab/blob/master/Step-3/app/src/main/java/xyz/vivekc/webrtccodelab/MainActivity.java">MainActivity.java</a> and <a href="https://github.com/vivek1794/webrtc-android-codelab/blob/master/Step-3/app/src/main/java/xyz/vivekc/webrtccodelab/SignallingClient.java">SignallingClient.java</a> files)</p><p>In short, what we do is, we try to establish a connection to the socket.io web socket, and when the connection is created, we send a room name to the server. The server would then create a new room if it is not created already or add you to the room if it is already present and has vacant space. (Room capacity is set to 2 for demo purposes)</p><p>If you are the creator, you need to send the offer to the other participant once they get connected to the session. The second participant would then receive it through the socket and create their answer and send it over through the socket to the initiator.</p><h3>Closing up</h3><p>Now that the SDP and ICE candidates are transferred through the socket from one participant to another, WebRTC will do its magic and transfer the Audio and Video streams between the participants.</p><p>Our guy now with his small weekend project, is now able to get in touch with his girl and speak out his mind 😬 (Everything worked out perfectly fine for him and that might even be the reason for this post to get delayed 😉)</p><p><em>The code for this step is </em><a href="https://github.com/vivek1794/webrtc-android-codelab/tree/master/Step-3"><em>here</em></a><em> on Github. In case you are wondering, this uses the latest gradle dependency for WebRTC and it might have some breaking changes to your code if you are using an older version of WebRTC. Make sure that you enable </em><strong><em>Java 8</em></strong><em> compatibility in your app and have another look where we create PeerConnectionFactory and PeerConnection instances. There have been some changes going on there and it might break your old code.</em></p><p>Get in touch if you face any issues!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de72b58ab31e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adventurous-android/getting-started-with-webrtc-part-4-de72b58ab31e">WebRTC for Android Guide— Develop video call app easily!</a> was originally published in <a href="https://medium.com/adventurous-android">Adventurous Android</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with WebRTC for Android — Loopback P2P calls]]></title>
            <link>https://medium.com/adventurous-android/peer-to-peer-video-calling-webrtc-for-android-4132fd0ac54?source=rss----cd32bf3b7535---4</link>
            <guid isPermaLink="false">https://medium.com/p/4132fd0ac54</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[webrtc]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Vivek Chanddru]]></dc:creator>
            <pubDate>Sat, 15 Jul 2017 13:42:22 GMT</pubDate>
            <atom:updated>2018-02-04T17:58:47.913Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xFyy_8vcIody08eRyXscpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lKGvz2CytK5LEnFvd9bq-w.png" /></figure><p>Peer to Peer video calling is on the rage for sometime and now every app has audio/video calling inbuilt. This tutorial series is all about exploring the possibility of providing such feature in an easy and understandable manner for beginners.</p><p>This tutorial series is loosely based on the <a href="http://codelabs.developers.google.com/codelabs/webrtc-web/">Codelabs for WebRTC</a>.</p><p>This part of the series is primarily based on <a href="https://codelabs.developers.google.com/codelabs/webrtc-web/#4">Step 2</a> of the above mentioned codelab where we use PeerConnection in WebRTC to transfer audio and video data between two peers in a same device.</p><p>This is <strong>Part 3</strong> of the series “<em>Getting started with WebRTC for Android</em>” and if you are new to this article, please make sure that you have read the previous parts of this series before continuing with this part.</p><p><strong>Part 1: </strong><a href="https://vivekc.xyz/getting-started-with-webrtc-for-android-daab1e268ff4"><em>Introduction to WebRTC</em></a></p><p><strong>Part 2: </strong><a href="https://vivekc.xyz/peerconnection-getting-started-with-webrtc-part-2-e426b08d1028"><em>Introduction to PeerConnection</em></a></p><p><strong>Part 3: </strong>Peer-to-Peer Video Calling — Loopback (this article)</p><p><strong>Part 4:</strong> <a href="https://vivekc.xyz/getting-started-with-webrtc-part-4-de72b58ab31e">Peer-to-Peer Video Calling with socket.io</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*464f12WjOZ3OztZgfc77ng.png" /></figure><p>Let us consider the following scenario where our courageous boy wishes to call the lady (to propose, of course!)</p><p>He plans to use an app which provides awesome video and audio calling feature. He wants to see her reaction when he proposes (awww). The following steps happens at both the ends of the peer connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X4iOI4qIKwoC8oK7AFdr6w.jpeg" /></figure><ul><li>Initially, our app creates an peer connection and an offer SDP. This offer contains the data about the calling peer and it is used to identify the codecs and other entities of the peer.</li><li>This offer is then stored as “Local Description” at the calling peer and is then sent over to the callee over some signaling mechanism (Typically, most of the systems use Websockets as the signaling medium. It might vary depending on your usage and requirements).</li><li>Once our app at the callee side receives the offer, it knows that there is a call to be established. It will store the “offer” as its “Remote Description” and creates the corresponding “Answer” SDP.</li><li>This answer SDP is similar to the caller’s offer SDP in that it will point out the details specific to that peer.</li><li>The app at the callee side, stores this “Answer SDP” as its “Local Description” and then sends it over through the signaling channel to the caller.</li><li>The caller receives this answer and stores it as its “Remote Description”.</li><li>Caller and Callee then transfers the Ice Candidates pertaining to them through the signaling channel. Upon receiving these candidates, the peer would add these candidates to their PeerConnection instance.</li><li>Once the transfer of Ice candidates are completed, the peers are effectively aware of how to transfer the media data between them. Transfer of media occurs through RTP and is taken care by the WebRTC framework.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dU_BIxomERIuJ3fQoKXtMw.png" /></figure><p>If you had a look at the <a href="https://codelabs.developers.google.com/codelabs/webrtc-web/#4">Step 2</a> of WebRTC codelabs, You might notice that they have created a loop between the caller and the callee.</p><blockquote>A single device acts as both the local peer and the remote peer thereby doing both offering and answering parts. Though it does not have any practical usage, it is better to pass through this step to have a deep understanding of how stuffs work.</blockquote><p>Have a look at the code below to figure out how it is implemented.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/931c3ba5749da5225513484344f5a1c7/href">https://medium.com/media/931c3ba5749da5225513484344f5a1c7/href</a></iframe><p>If you take a look at the above code, We have 3 methods.</p><p>start() method essentially creates the local audio and video source and adds them to a SurfaceViewRenderer (this is provided by WebRTC so that we can draw our video frames directly to this view).</p><p>hangup() method is just a simple piece of code that clears off all the PeerConnection instances</p><p>call() is where all the fun happens.</p><ul><li>We create two peer connection instances (one for local peer and another for remote peer). Once those peers are created, we make the local peer create an Offer that is set as its Local Description and also the Remote Description of the remote peer.</li><li>We then make the remote peer to create answer which is set as its Local Description and the local peer’s Remote Description.</li></ul><p>We also have the onIceCandidateReceived() method whose work is to set the Ice candidates received from one peer to another peer.</p><p>You can take a look at Step-2 folder of the <a href="https://github.com/vivek1794/webrtc-android-codelab/">Git repository</a> for the full working code of Loopback peerconnection.</p><p>All is going well now. Our app will be able to show your face to you, just like we did in the <a href="https://vivekc.xyz/getting-started-with-webrtc-for-android-daab1e268ff4">first</a> part. Except that, this time our app is showing the face through a peer connection.</p><p>We got the basics working. We have two peers which transfer the offer and answer SDPs along with the candidates and now they both can transfer the data. But this is not the real case. Real people call each other and not themselves. Extending this solution to a real use case is easy. We just need a medium to transfer the SDPs and some STUN and TURN setup.</p><p>This has become too large for a single post. See you soon(hopefully!) with the grand finale where you will have a working Peer-to-Peer enabled video calling app.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F1c98eb%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F1c98eb%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/e13ad3d9d93a8ba1985873d38d7d3b42/href">https://medium.com/media/e13ad3d9d93a8ba1985873d38d7d3b42/href</a></iframe><p>Do press the green heart to show some love! For more droid-y posts, follow <a href="https://vivekc.xyz/latest">Adventurous Android</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4132fd0ac54" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adventurous-android/peer-to-peer-video-calling-webrtc-for-android-4132fd0ac54">Getting started with WebRTC for Android — Loopback P2P calls</a> was originally published in <a href="https://medium.com/adventurous-android">Adventurous Android</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PeerConnection — Getting Started with WebRTC — Part 2]]></title>
            <link>https://medium.com/adventurous-android/peerconnection-getting-started-with-webrtc-part-2-e426b08d1028?source=rss----cd32bf3b7535---4</link>
            <guid isPermaLink="false">https://medium.com/p/e426b08d1028</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[peer-to-peer]]></category>
            <category><![CDATA[webrtc]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vivek Chanddru]]></dc:creator>
            <pubDate>Sat, 01 Apr 2017 08:28:09 GMT</pubDate>
            <atom:updated>2018-02-04T17:58:29.473Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_IHvJa9ctmOOQOs7j8Uvfw.png" /></figure><p>If you are one of the few developers who is looking to use WebRTC in Android native code and are stuck without a tutorial resource, this guide is for you.</p><p>If you landed up here accidentally, go back to basics in the <a href="https://vivekc.xyz/getting-started-with-webrtc-for-android-daab1e268ff4">Part 1</a> of the series to get an idea of what is discussed here.</p><p>This is <strong>Part 2</strong> of the series “<em>Getting started with WebRTC for Android</em>” and if you are new to this article, please make sure that you have read the other parts of this series too.</p><p><strong>Part 1: </strong><a href="https://vivekc.xyz/getting-started-with-webrtc-for-android-daab1e268ff4"><em>Introduction to WebRTC</em></a></p><p><strong>Part 2: </strong><a href="https://vivekc.xyz/peerconnection-getting-started-with-webrtc-part-2-e426b08d1028"><em>Introduction to PeerConnection</em></a><em> </em>(this article)</p><p><strong>Part 3: </strong><a href="https://vivekc.xyz/peer-to-peer-video-calling-webrtc-for-android-4132fd0ac54">Peer-to-Peer Video Calling — Loopback</a></p><p><strong>Part 4:</strong> <a href="https://vivekc.xyz/getting-started-with-webrtc-part-4-de72b58ab31e">Peer-to-Peer Video Calling with socket.io</a></p><h3>Looking back…</h3><p>Here is a glance of what we saw in part 1 of the series.</p><ul><li>WebRTC is a peer to peer connection framework which can be used to provide high-quality audio/video/data transfer between peers.</li><li>WebRTC for the Web is straightforward. In Android, We have to write a lot of verbose code to make it work right.</li><li>WebRTC is available by default in almost all of the latest browsers. For the mobile platform, we have to include the <a href="https://webrtc.org/native-code/android/">peer connection native library</a> to make it work.</li><li>In <a href="https://vivekc.xyz/getting-started-with-webrtc-for-android-daab1e268ff4">part 1</a> of the series, we saw how to get the video from the user’s camera using WebRTC framework classes</li><li>We used VideoCapturer class to capture the video from the user’s camera</li><li>VideoSource was created using the capturer instance which is then used to create the VideoTrack instance.</li><li>This VideoTrack was rendered in a local SurfaceViewRenderer</li></ul><p>Now, this was a long time back, and I had to take a break after the part 1 of the series. Let us look more into how PeerConnection works and how to implement it in Android.</p><h3>Tell me what PeerConnection is?</h3><p>First, let us establish a fact. WebRTC is based on Peer-to-Peer connection (Or simply P2P). So what is P2P? Here is what <a href="https://en.wikipedia.org/wiki/Peer-to-peer">Wikipedia</a> has to say about P2P</p><blockquote><strong>Peer-to-peer</strong> (<strong>P2P</strong>) computing or networking is a distributed application architecture that partitions tasks or workloads between peers. Peers are equally privileged, equipotent participants in the application. They are said to form a peer-to-peer network of nodes.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*5zeQvxO-hbCGSBh8XivpuA.jpeg" /></figure><p>If you are someone who is still in the dark, the more humane explanation would be,</p><blockquote>A peer-to-peer (P2P) network is one where two or more devices are connected and share their resources without having to go through a separate server.</blockquote><p>So in simpler terms, by using WebRTC, we could share the audio/video streams directly with the other peers without the need for an external server computer. This is a huge benefit for companies as <em>their infrastructure are not overloaded with the bulk of audio/video data</em>.</p><ul><li>A Peer is a device connected to the network.</li><li>Sharing of data between peers is possible only when the network to which they are connected allows it. We will see more about it when we see about STUN/TURN.</li><li>In WebRTC, we use a concept called “Rooms” to identify the peers who are connected to each other.</li><li>Many peers can be connected to a single room thereby sharing their resources with other peers in the same room.</li><li><strong><em>Signaling</em></strong> (or Signalling if you are British) is needed to intimate the peers about the other peers in the room to establish a P2P connection between them.</li></ul><h3>Signaling</h3><p>Even though WebRTC takes care of the P2P communication, we need to specify some signaling mechanism so that the peers can communicate. Signaling is not included in WebRTC so that the developers could have the freedom of choosing their own mechanism for their needs.</p><p>Isolating signaling from the core WebRTC gives freedom to plug’n play whatever the infrastructure the developer/organization has already set up.</p><blockquote>WebRTC works only with secure networks. It gives the guarantee that the data transfer is done in a secure channel. It is up to the developer to use a secure channel for signaling messages.</blockquote><p>WebRTC has two major components — <strong>Offer</strong> and <strong>Answer</strong>. They both are nothing but metadata. They provide the audio/video encoding formats available in the device, their network details and much more.</p><p>The offer and answer are encapsulated in a format which is called <strong>Session Description Protocol</strong>, or simply, <strong>SDP. </strong>Read <a href="https://www.ietf.org/archive/id/draft-nandakumar-rtcweb-sdp-08.txt">this IETF document</a> if you want to learn more about the format.</p><p>This SDP is transferred among the peers in the network so that they would know about the other peers. This data would be used by WebRTC to come to an agreeable audio/video format that would be supported by most of the peers along with the route through which the communication could take place.</p><p>Let’s assume now Bruce Wayne calls Clark Kent to ask him to surrender. Wayne, the gadget freak that he is, wants to call Kent in his private P2P network because showing bat signal is too mainstream.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*dYhznnZZnHP-ingmEAbgJQ.gif" /></figure><p>Here is what happens in the background</p><ul><li>Wayne creates an <strong>Offer</strong> and sends it to the “<strong>SuperHeroes</strong>” room.</li><li>He stores the Offer safely in his cave so that he would remember it.</li><li>Kent, being a superhero, receives the offer, stores it safely in his fortress as Wayne’s personal information.</li><li>Being a generous person and not knowing what the call is about, Kent <strong>answer</strong>s the offer sent by Wayne after storing his answer safely.</li><li>Wayne receives the answer from Kent and stores it safely again.</li><li>Wayne and Kent also share some interesting additional information like how both have a mother named Martha (They share IceCandidates which specify their audio/video and other important details — More on it below)</li><li>Now Wayne and Kent has the meta information about them and the information about each other. Wayne could now establish a direct link to Kent, and we all can have some action time!</li></ul><p>Here, When Wayne creates the offer, he is called the “<strong>initiator</strong>” of the call. The offer that he created and stored is his “<strong>local description.”</strong></p><p>When Kent receives the offer, he stores it as the “<strong>remote description</strong>” of his peer. His answer is his “<strong>local description.</strong>”</p><p>This transfer of offer and answer as SDP can happen over any medium. It could be WebSockets, Google cloud messaging system, XMPP, SIP, RTCDataChannel, etc. This choice available to the developer to select the signaling medium is the major advantage for WebRTC.</p><p>Even though the P2P connection does not require a server connection, the signaling part of WebRTC does require a server to manage the sessions, rooms and their participants. The signaling messages are relatively small in comparison with the bulk audio/video data. This would take a few KB of data transfer over an entire call session.</p><blockquote>Even though signaling messages are small, if you want to support a huge customer base, you might have to think about scaling the signaling system to support a huge number of concurrent calls made.</blockquote><h3>STUN and TURN</h3><p>Now that we know how to signal the participants of a caller, we can establish a call, right? Yes, in an ideal world where the villains like NAT gateways and firewalls are not there. Unfortunately, we are not living there.</p><p>WebRTC is equipped with handling those villains. But we might have to guide it just like how we helped it with signaling. There is a more detailed version that explains what STUN, TURN are and what problems they solve.</p><p><a href="https://www.html5rocks.com/en/tutorials/webrtc/infrastructure/#after-signaling-using-ice-to-cope-with-nats-and-firewalls">WebRTC in the real world: STUN, TURN and signaling - HTML5 Rocks</a></p><p>In Simpler terms,</p><ul><li>The P2P connection can happen only when the peer knows the public ip:port combination of the other peer. This is not possible in NAT-protected networks.</li><li>STUN is a public server whose only work is to find out the public ip:port of the incoming request and send that address as the response. Peers can use STUN to know their public ip:port (NATs doesn’t give away that information directly to the peer. Hence the STUN — <strong>Session Traversal Utilities for NAT</strong>)</li><li>STUN is not bandwidth intensive, and there are many public STUN servers that we could use.</li><li>Again in an ideal world, where NATs don’t block the UDP/TCP audio/video streams, we could make the WebRTC communicate through NATs with the STUN response we got.</li><li>But, in cases where NAT is so restrictive, TURN (Traversal Using Relays around NAT) is used.</li><li>TURN servers are relays that act as a proxy for peers. TURN servers have their public ip:port and hence the peers can communicate directly with them even if they are behind the firewall.</li><li>Each peer sends their media data to the TURN server which relays it to another peer.</li><li>Unlike STUN which handles a low volume of data, TURN handles large media streams and hence needs to be scalable for production apps.</li><li>TURN servers are costly and are not available for free.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*DtJY0aXmUREIqoFLUDmvTg.png" /><figcaption>A typical product app architecture using STUN and TURN</figcaption></figure><blockquote><strong>TURN is used to relay audio/video/data streaming between peers, not signaling data!</strong></blockquote><ul><li>TURN is like a messenger who carries the messages from one person to another. It does nothing else to the media streams.</li></ul><h3>Media Servers</h3><p>WebRTC works perfectly for two peers to communicate with each other. Imagine what will happen when a group of peers wants to communicate? (Group Calls, duh?)</p><p>Consider a full mesh network where every peer is connected to every other peer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*54zJRaa-cWLOJ1LRfSA38w.png" /><figcaption>The full-mesh topology</figcaption></figure><ul><li>This approach works well for a smaller number of peers in a connection. But, when the number grows beyond control, due to excessive redundancy and higher bandwidth requirements, it fails miserably.</li><li>This approach is not suitable for low-bandwidth devices like our smartphones.</li><li>In comes the Multipoint Control Unit (MCU). These are specific hardware/software technology which helps in creating a <strong>star topology</strong> instead of the <strong>full-mesh topology.</strong></li><li>The Media server acts as the peer for all the peers. It will keep track of all the peers in the network and transfer the data from other peers.</li><li>Each peer in star topology will be connected only to the MCU and will not have any network connection to the other peers in the network.</li><li>See below for more information regarding MCU and Media Servers.</li></ul><p><a href="https://www.html5rocks.com/en/tutorials/webrtc/infrastructure/#beyond-one-to-one-multi-party-webrtc">WebRTC in the real world: STUN, TURN and signaling - HTML5 Rocks</a></p><p>After all these theories, if you are like this,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*BoxYAVDQa9CRawUSEi0DHA.jpeg" /></figure><p>Wait for the next part in this series to find out more how all these fits in together to create an excellent Video calling android application.</p><p>Until then, See ya!</p><h3>References</h3><ul><li><a href="https://www.html5rocks.com/en/tutorials/webrtc/basics/">https://www.html5rocks.com/en/tutorials/webrtc/basics/</a></li><li><a href="https://www.html5rocks.com/en/tutorials/webrtc/infrastructure/">https://www.html5rocks.com/en/tutorials/webrtc/infrastructure/</a></li><li><a href="https://codelabs.developers.google.com/codelabs/webrtc-web/#0">https://codelabs.developers.google.com/codelabs/webrtc-web/#0</a></li><li>Of course, Google ;)</li></ul><p>The next part of the series is out. Do check it out for more info on how to get started with WebRTC for Android.</p><p><a href="https://vivekc.xyz/peer-to-peer-video-calling-webrtc-for-android-4132fd0ac54">Getting started with WebRTC for Android — Loopback P2P calls</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F1c98eb%3Fas_embed%3Dtrue&amp;url=https%3A%2F%2Fupscri.be%2F1c98eb%2F&amp;image=https%3A%2F%2Fupscri.be%2Fmedia%2Fform.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a4e917445080149a4216517ed5b188f/href">https://medium.com/media/0a4e917445080149a4216517ed5b188f/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e426b08d1028" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adventurous-android/peerconnection-getting-started-with-webrtc-part-2-e426b08d1028">PeerConnection — Getting Started with WebRTC — Part 2</a> was originally published in <a href="https://medium.com/adventurous-android">Adventurous Android</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happened at DroidConIN 2016 — Day 2]]></title>
            <link>https://medium.com/adventurous-android/what-happened-at-droidconin-day-2-ed7d656195c2?source=rss----cd32bf3b7535---4</link>
            <guid isPermaLink="false">https://medium.com/p/ed7d656195c2</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[droidcon]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[india]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Vivek Chanddru]]></dc:creator>
            <pubDate>Tue, 15 Nov 2016 04:13:54 GMT</pubDate>
            <atom:updated>2016-11-20T06:56:21.924Z</atom:updated>
            <content:encoded><![CDATA[<p>Searching what the biggest Android technical event had in store for the developers? If you haven’t read my view on what happened on Day 1 at DroidConIN, go ahead and open the link below</p><p><a href="https://vivekc.xyz/experience-at-droidconin-2016-9c26a9d0eb7c">What Happened at DroidConIN — Day 1</a></p><p>Day 2 of DroidCon at the Garden City started off well and kept the tempo throughout the day. It was fast paced, informative and fun! Without further ado, let’s dive deep to know more on each session.</p><h3><a href="https://speakerdeck.com/mariostallone/react-native-in-production">React Native in Production</a></h3><p><em>Mario Stallone, Myntra</em></p><p>We were a bit late for the session (blame the nice breakfast!). But hey! The session started late too ;) Mario Stallone took the stage and gave an interesting talk on how React Native is the next big thing for cross-platform development.</p><ul><li>React Native lets you build native Android and iOS apps using JavaScript (YESSS!). Though the logic is written in JS, the apps are compiled to have native views and not like the neat little trick which PhoneGap/Sencha uses.</li><li>This is NOT a Webview renderer. The Views are converted to Native Android Views.</li><li>React Native provides faster builds and provides excellent support for developers</li><li>You could share the business logic between Android and iOS while sticking to the native views for each platform</li><li>No more waiting for Google PlayStore to update the app. App updates are instantaneous.</li><li>Bug fixes need not wait for longer period to be pushed out to users</li><li>Splitting the app into Native screens and React Native screens are more common and useful than going full React Native screens.</li><li>Have some common Routing class which makes the transition from one screen to another. An activity doesn’t need to know which native activity or React Native screen it is calling. Routing classes provides the abstraction required</li><li>React Native is under active development and hence it is necessary to keep the app updated with latest React Native library</li><li>Might have to spend time in writing Bridges for something that is not available out of the box</li><li>Might have to write a lot of wrappers to make it communicate with the existing native code</li><li>Tracking crashes are pretty hard. All the crashes are compiled under a single crash report</li><li>Android doesn’t ship with JS runtime and hence it has to be bundled with the apk. The size of the app will thus increase</li><li>Works great for apps that does not require much hardware integration</li><li>The app takes time to load (cold startup time) as the JS runtime has to be initialized. It is always better to have native and React Native screens combined to get better user experience.</li></ul><h3><a href="http://slides.com/harshitbangar/deck#/">Scalable Espresso Testing</a></h3><p><em>Harshit Bangar, Uber</em></p><p>Next up was a crisp talk from Harshit on Espresso testing.</p><ul><li>Espresso testing has mainly 3 components — ViewMatchers, ViewActions, and ViewAssertions</li><li>ViewMatcher — they are used to locate the view in the current view hierarchy</li><li>ViewAction — An action that is to be performed on the view from ViewMatcher. It could include actions like click()</li><li>ViewAssertion — A condition that has to be satisfied to mark the test case as successful.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6mIC0J2VrUfgZ1DwjTb4g.png" /></figure><ul><li>A/B Tests could be simulated using Espresso</li><li>Custom ViewMatchers and Rules could be defined by extending the corresponding classes.</li><li>Replay and Record the network responses to be sure that there are no server side errors that creep up in the APIs.</li></ul><h3>Android Development at Dropbox</h3><p><em>Piotr Gurgul, Dropbox</em></p><p>This was the most anticipated session for the event. The event was right after the morning tea and Piotr took us through his experience at Dropbox and how they handle development at Dropbox. It was an eye-opener and a lot of new things could be adopted in our day-to-day Android development to make it better.</p><ul><li>Dropbox makes the code repository easy to understand and every new employee makes a commit on the first day at his job!</li><li>Extensive training is given to the employees before they work on the product. Training includes development process at Dropbox, Coding standards, and other fun things ;)</li><li>They maintain a single repository for Android,iOS and other platforms unlike most of us who go for different repositories for different platforms. Piotr says that this setup gives more collaboration and developers finds it useful</li><li>Dropbox’s in-house <a href="http://paper.dropbox.com/">Paper</a> is used for the communication between developers and designers</li><li>Slack integration is used pretty much for everything and it helps developers not waste time looking for tasks or checking for the latest commit made to the repository</li><li><a href="https://github.com/phacility/phabricator">Phabricator</a> and <a href="https://github.com/phacility/arcanist">Arcanist </a>— The two tools that Dropbox heavily relies on. Tasks, Bugs, Milestones, Code review and almost everything is taken care using these tools</li><li>UI views are created as a library and given to the developers so that the design will be consistent. Similarly, the components are given to designers so that they could plug them anywhere required for consistent UI</li><li>He gives the most valuable advice — Fail Fast — Fail immediately and visibly. There is nothing wrong in failing and it is always better to accept the failure and learn from the mistakes</li><li>Static code analysis and Lint checks are used to find out errors at an earlier stage. Code with lint error is not allowed to be committed to the repository</li><li>Use Annotation and Lint extensively. Annotations like CallSuper, StringRes,ColorRes, LayoutRes etc gives a better idea of what the method should take as param and how it should behave with it</li><li>Android devices are subjected to configuration changes such as orientation change or addition of an external keyboard etc. The app should be capable of handling such configuration changes and do the necessary actions to be performed</li><li>When you decide to give i18n support for your app, make sure that there are placeholders for numbers in the text that is given to the translator. Some languages will rearrange the position of numbers and it is always better to make things clear with the translator</li><li>All the dev changes are maintained in a separate branch. These can be pushed to the master branch only when it has passed code reviews and QA. That way, only the best code gets pushed to production</li><li>The CI is configured to auto format the code so that a proper standard is maintained throughout the app</li></ul><h3><a href="https://speakerdeck.com/saketme/deflating-the-layoutinflater-droidcon-india-2016">Deflating the LayoutInflator</a></h3><p><em>Saket Narayan, Uncommon</em></p><p>Saket took the stage after the lunch break. Again we were a few minutes late (blame the food again?! No, this time it was just us roaming around the stalls), but we were able to catch up with his talk. The talk is one of its own kind, and I particularly liked how his slides were and how well he presented everything.</p><ul><li>LayoutInflator is basically what converts the XML files that we write to Java Objects</li><li>They are the basic building blocks of Android UI</li><li>LayoutInflator uses 3 components — XMLPullParser, AttributeSet and Creating View objects</li><li>XMLPullParser is the one responsible for parsing the XML files</li><li>AttributeSets are the base for each view defined in the XML file.</li><li>They provide information on what the view is, how they are displayed, what they display and their behavior</li><li>LayoutInflator also makes sure to parse the dimens and other references provided to the AttributeSets</li><li>Precedence of attributes is also taken care by the inflator service</li><li>Creating View Objects includes finding the view’s source and <em>Reflection (Slow!)</em></li><li>The inflator service creates the view objects by delegating the work to the “Factories” or by doing the job by itself when it couldn’t use the Factories</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3lc3G3YMry8Ycwik9Ms1JA.png" /></figure><ul><li>Common Factories include the Activity (Which implements LayoutInflater.Factory2) or the well known AppCompat</li><li>Instantiating view by itself uses reflection to load the class corresponding to the View (Custom View or the Framework View)</li><li>AppCompat is a simple Factory which is used to back-port material design to pre-lollipop devices</li><li>AppCompat reduces the need for custom selector drawables and provides most of the controls through style items</li><li>AppCompatInflator replaces the normal Framework views (like TextView) with its equivalent tint-aware AppCompat view (like AppCompatTextView)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pq8EHUcC_T5bDY1ck7CvcQ.png" /></figure><ul><li><a href="https://github.com/chrisjenx/Calligraphy">Calligraphy</a> is a library which can be used to apply fonts to a View without the need to write custom views (Useful indeed!)</li><li>This is possible since the LayoutInflator of Calligraphy takes care of applying the typeface for the view automatically based on the <em>fontpath</em> attribute</li><li>He then went on to show how formatting could be done without the need for a custom view but with his own library —<a href="https://github.com/Saketme/Balloon"> Balloon</a> (Pretty cool and nicely done. Use it if you need to format a lot of text in your app)</li><li>It works simply by creating a config and registering the attribute with a listener. This listener would then take care of formatting the text (You might have to write your own implementation though)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ztnyKTXSnCOjobEDg7qEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7prSJnWQqEsNUVc3lgSiVw.png" /></figure><ul><li>He then went on to talk about the challenges that he faced while developing this library. It basically had to do with making the inflator service use the BalloonInflatorService instead of the framework’s inflator service. This could be achieved by adding the following lines</li></ul><pre>@Override                           <br>protected void attachBaseContext(Context newBase) {                               super.attachBaseContext(BalloonContextWrapper.wrap(newBase));                           }</pre><h3><a href="https://speakerdeck.com/adityasharat/proteus-android-layout-engine">Proteus: Android Layout Engine</a></h3><p><em>Aditya Sharat, Flipkart</em></p><p>Ever wondered how Flipkart managed to change its contents without the need for an app update? Aditya came up the stage to clear the doubts about that. He introduced the product from Flipkart incubator —<a href="https://github.com/flipkart-incubator/proteus"> Proteus</a> — A JSON LayoutInflater with Data Bindings!! (How Cool is that?!)</p><ul><li>Traditional release cycles would make the app development slow. It will take a number of days just to get a minor bug fix out to the PlayStore after passing through QA and reviewers</li><li>A new app update is required just to change the color of a text or an icon or the positioning of the views</li><li>Introducing Proteus — A drop-in replacement for LayoutInflator which inflates layout at runtime unlike the traditional LayoutInflator</li><li>Proteus takes 3 major JSON files — the layout file, data file and the styles</li><li>The JSON which describes the layout is exactly the same as the traditional XML layouts. It uses <em>“type” </em>to specify the View/ViewGroup and “<em>children</em>” array to specify the child views of the ViewGroup</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-IeRAeGAY9rnXIDc7EYz9A.png" /></figure><ul><li>Since LayoutInflator doesn’t support our plain old XML files (Layout files are converted to bytes at compile time and R files are generated), Proteus uses JSON as their medium of communication</li><li>LayoutInflator is already a painful process with lots of Reflection (More on that was already covered in the previous session)</li><li>Proteus allows us to build views and compose layouts with out of the box support for almost everything that you need to create the UI</li><li>Proteus also takes care of run-time data binding and formatters</li><li>Styles are more like a hybrid child of our own styles.xml and the dear CSS (Yeah! I remember you!). It could be used to change the look of views while the layout json file allows us to set the positioning of the views</li><li>Out-of-the-box support for shape drawables and Animations!!</li><li>CustomViews could be added to Proteus. Though we might have to add the code describing how the data will be parsed using the Parser implementation.</li><li>Since CustomViews might not be present in some older versions, Proteus gracefully handles fallbacks and has fail-safe methods built into the library</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xBi0h-DHi97-wGzLkpiNHg.png" /></figure><ul><li>One major drawback is, we cannot send the behavior of the view. We can specify how the views could be positioned but not how the views will behave for particular events</li><li>Behavior has to be programmed and any change to the behavior of a view will need a traditional app update</li><li>Most useful for apps that do not have the default behavior change constantly</li><li>Flipkart has plans to make the medium of communication as an interface than making it compulsory for us to use JSON (though we may not know when they will be available)</li><li>There are other libraries that kind of does this already —<a href="https://github.com/Avocarrot/json2view"> Json2View</a>, <a href="https://github.com/alibaba/AndFix">AndFix</a>, <a href="https://github.com/jmarranz/itsnat_droid">ItsNat Droid</a> and <a href="https://github.com/facebook/react-native">React Native</a> are some of them</li></ul><h3>Building Interfaces with ConstraintLayout</h3><p><em>Neha Dhanwani, Reliance Jio</em></p><p>Next up was Neha who gave a crisp talk on the all new ConstraintLayout, which Google introduced recently. Some points that were discussed,</p><ul><li>Generally, app development goes through a lot of cycles and over a period of time, the app layout becomes complex with multiple nested views</li><li>This complex layout will cause lagging when rendered and that is why it is advised to have fewer hierarchies</li><li>ConstraintLayout works simple — It helps you assign constraints to views (that are either siblings or parent)</li><li>Anchors are used to provide connection between two views</li><li>ConstraintLayout works well and helps to flatten the view hierarchy</li><li>When compared with the traditional LinearLayout or RelativeLayout, the depth of each view inside the viewgroup is much lower and the performance gain was measured as a minimum of 10% increase.</li><li>ConstraintLayouts are NOT RelativeLayouts — They are more like RelativeLayouts with super power</li><li>The new Android Studio has editor page for ConstraintLayouts. It has 3 panes — Preview pane, Blueprint/editor pane and the property pane</li><li>Android Studio provides options to migrate the existing traditional layout into a ConstraintLayout</li><li>3 different handles are used — Resize handle, side constraint handle and baseline construction handle.</li></ul><h3><a href="http://www.slideshare.net/DevavrataSharma/brillo-and-weave-android-iot">Brillo and Weave — IOT, the Next Thunderstorm</a></h3><p><em>Devavrata Sharma, Techjini</em></p><p>This talk from Devavrata Sharma on IoT was a refresher when everyone was too much into Android. It was an awesome talk and a much needed one if we have to guess by how things are shaping up.</p><ul><li><a href="https://developers.google.com/brillo/">Brillo </a>— A new Android and Not-So-Android OS from Google for IoT</li><li>It is an attempt to unify the different OS available for IoT platform. Vendors have their own OS with their own drivers. Brillo aims to bridge the gap and Google wants every vendor to run Brillo so that it will be helpful for app developers</li><li>Brillo is based on Android at the base level. It doesn’t use the Core Applications, Applications Framework and the Runtime used in the Android architecture.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ibr1_jzNPuWCa-6GkiZhWw.png" /></figure><ul><li><a href="https://developers.google.com/weave/">Weave </a>— It is the communication channel which enables the link between devices</li><li>IoT requires the control messages to be passed to the IoT enabled devices and this communication from a mobile app/website is carried out through the Weave channel</li><li>Weave can be used for communication between the devices either directly or through the cloud which is taken care by Weave</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KpLESVoyinJ1rGBw7UVRBw.png" /></figure><ul><li>Brillo and Weave are developed with Security in mind. They provide high level security by providing SELinux, Verified Boot, User account controls and ofcourse, TLS data encryption</li><li>Weave has excellent Metrics and analytics which could help in finding out issues in the IoT enabled devices. It also provides robust OTA updates for the device.</li></ul><h3><a href="https://drive.google.com/file/d/0B3MSpfqPxqE4b0dxM3BuUEM2bGs/view?usp=sharing">Android Instrumentation: Diagnose &amp; Hot Fix Your Live Apps, Realtime</a></h3><p><em>Mudit Krishna Mathur, Hansel.io</em></p><p>Mudit from Hansel.io took the stage to wrap things up for the event. His talk is the last talk for the grand event and he did it with confidence backed by a truck full of information. We saw how Proteus could help us in changing how the application looks at Runtime. But what if we want to fix a crash immediately and it cannot wait for a traditional release? This talk is for those seeking to fix things on the fly (or Over the Air, if you would like)</p><ul><li>Applications are prone to crashes and logical issues which could result in loss of revenue, bad ratings and the users never setting their fingers over your app icon :(</li><li>There are a lot of Analytics tools that could help in knowing the user behavior and could help in finding out if there are any crashes. But these are just static tools. They can only report the errors and cannot fix them</li><li>Instrumentation is just the way to do it. Instrumentation means addition of bytecode to existing methods at runtime and gathering data from network,CPU,GPU and memory</li><li>Some instrumentation tools are Android monitor, <a href="https://eclipse.org/aspectj/">AspectJ</a>, Dex Maker and ASMDX</li><li>Aspect Oriented Programming (AOP) — is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns</li><li>It does so by adding additional behavior to existing code (an <a href="https://en.wikipedia.org/wiki/Advice_%28programming%29">advice</a>) <em>without</em> modifying the code itself, instead separately specifying which code is modified via a “<a href="https://en.wikipedia.org/wiki/Pointcut">pointcut</a>” specification</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-F9d9sa1MFlinJ-WFdkwXQ.png" /><figcaption>Here, FooO is the original method, but AOP makes Foo to be executed instead of FooO</figcaption></figure><ul><li>This requires you to specify certain methods that are to be executed when an action and pointcut params are provided through the internet via a config file</li><li>The action should be executed when the pointcut param is satisfied</li><li>The config file tells what action to be performed and at what method or class the action should be carried out</li><li>We could write methods that could enable/disable logging, change the return value of a function or prevent a method from being called itself, to name a few.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*akXhcIDAQnxTBF-4sK6s1Q.png" /></figure><ul><li>The actions have to be handled inside the app already. AOP just enables us to switch on/off the feature. We cannot send a new Java code over the air and expect it to run properly</li><li>Using Proguard should not be a problem for most of the cases</li><li>Performance could be a bit low as reflections might be used. So exclude the classes that will not have need for runtime hotfix</li></ul><h3>My Take on the Event</h3><ul><li>The sessions were well thought out and executed perfectly</li><li>The volunteers were awesome, helpful and kind. The event went without any major goof-ups except for a few mic disturbance</li><li>If you are going to start developing a new app, then it is high time that you consider using <em>Java 8, RxJava, Data Binding</em> and an architecture like <em>MVP or MVVM </em>to combine all of these. And Yeah, Keep calm and Write Unit tests!</li><li>Follow certain coding standards and everything will fall into place automatically</li><li>Proteus with Realtime instrumentation could work well together to give an app update experience like never before</li><li>This kind of knowledge sharing event should be conducted often and should not be limited to a particular geography.</li></ul><p>Well, that’s it. Two days of fun and being together with the Android developer community has taught a lot and this kind of event always makes you feel that there is no limit to what you can learn still. By the end of the day, we left the MLR Convention Hall with a bag full of goodies from various sponsors and were getting ready to spend the next day exploring the ever busyc city of Bengaluru. Interested to know what we did? head over <a href="https://medium.com/@agilanbtdw/adding-more-green-to-the-garden-city-droidcon2016-d25b2d9b0893#.olm2uhanz">here!</a> :)</p><p>Ciao</p><p><em>P.S: All the images are taken from the slides of the respective speaker. Click on the title to view the slides.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed7d656195c2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adventurous-android/what-happened-at-droidconin-day-2-ed7d656195c2">What Happened at DroidConIN 2016 — Day 2</a> was originally published in <a href="https://medium.com/adventurous-android">Adventurous Android</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happened at DroidConIN 2016 — Day 1]]></title>
            <link>https://medium.com/adventurous-android/experience-at-droidconin-2016-9c26a9d0eb7c?source=rss----cd32bf3b7535---4</link>
            <guid isPermaLink="false">https://medium.com/p/9c26a9d0eb7c</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[india]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[droidcon]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vivek Chanddru]]></dc:creator>
            <pubDate>Sun, 13 Nov 2016 04:15:48 GMT</pubDate>
            <atom:updated>2016-11-15T05:36:20.470Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IwTDFmmRHEcfz2iEnglKUg.png" /></figure><p>We as a group of 5 from Zoho, Went to <a href="https://droidcon.in/2016/">DroidConIN</a> conducted at MLR Convention Hall, JP Nagar, Banglore. Here are the takeaways that we had from the event :) This post is purely about the technical sessions that happened at DroidCon. If you want to know about our experience there, Check out my friend <a href="https://medium.com/u/458015f69050">Agilan Anandan</a>’s post <a href="https://medium.com/@agilanbtdw/adding-more-green-to-the-garden-city-droidcon2016-d25b2d9b0893#.o6s8heqg4">here</a>.</p><h3><a href="https://speakerdeck.com/soham/firebase-realtime-database">Firebase Realtime Database Deep Dive</a></h3><p><em>Soham Mondal, Triveous</em></p><p>The event kicked off with a talk from Soham on Firebase Realtime Database. He talked about using Firebase Realtime Databases using a demo app which listed movies and enabled users to chat/poll realtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZubiZc4PTgstpSy20_t9Q.png" /></figure><ul><li>Setting data from a Realtime DB is very simple using the database reference provided by Firebase</li><li>Getting a value from DB can be done using ValueEventListener or a ChildEventListener</li><li><a href="https://firebase.google.com/docs/database/android/offline-capabilities">Offline storage</a> can be used by setting <em>setPersistenceEnabled(true)</em> on the FirebaseDatabase instance</li><li>You can also use <em>keepSynced(true)</em> to make Firebase sync the data from cloud to local without the need for explicit listeners</li><li>Firebase’s Realtime Database is a NoSQL Database. Data are stored in the form of JSONObjects/JSONArray. We have to make sure that the structure of the JSON is efficient and optimized for the use cases of the app</li><li>Sync in the background should be notified using Firebase Admin SDK</li><li>No Search queries are possible</li><li>It needs Play Services to work and hence won’t be of any use if the app is targeted for Chinese mobile devices that don’t have Google Play.</li><li>Can compete with Realm for small use cases. For larger use, Realm far outweighs Firebase in Realtime Database (At least for now!)</li></ul><h3><a href="https://speakerdeck.com/babuasp2003/effective-gradle-scripts-for-android-projects">Effective Gradle Scripts for Android Projects</a></h3><p><em>Arun Babu A S P, Dailyhunt</em></p><p>Next up the stage was Arun Babu. He gave the audience a shock by talking about Glide (A popular image processing library). Everyone was pulling out their hairs as the schedule mentioned that the crisp-talk for 20 minutes was going to be about gradle. He then turned the topic towards Gradle scripts using Glide as the demo app and took all of us for a joyful ride. His agenda for the session had 7 items.</p><p><strong>1. Break Your Code</strong></p><ul><li>Over a period of time, projects tend to accumulate a lot of Class files, packages, and modules. It slows down gradle build, makes it hard to do code reviews and module ownership becomes a challenge.</li><li>To solve this, Create multiple projects and use them as aar files from the local maven repo during build time.</li></ul><p><strong>2. Composite Builds</strong></p><ul><li>Create a build that simply includes other builds</li><li>It will be useful for larger applications but is limited to Gradle versions 3.x and Android Studio doesn’t provide this support right now</li></ul><p><strong>3. Declare Dependencies</strong></p><ul><li>Android support libraries are great. But keeping track of the version becomes a huge task for larger projects.</li><li>Declare dependency version in the root build.gradle file and use them in the app level build.gradle dependency</li></ul><pre>compile “com.android.support:support-v4:${SUPPORT_V4_VERSION}”</pre><ul><li>Or have a separate dependency.gradle file and use them</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V30gx7qWXhlcnEcW9wzz6A.png" /></figure><p><strong>4. Secure Passwords</strong></p><ul><li>DO NOT hardcode the signingConfigs in your build.gradle and add them to git/Mercurial/SVN. Load them from a file which is off-VCS</li></ul><p><strong>5. Flavor Dimensions</strong></p><ul><li>Create multiple product flavors as needed. One for beta, one for debugging, one for QA and one for Production(release) seems a minimum requirement.</li><li>You could change the sourceSets for each of the flavors, thereby creating multiple behaviors without much code duplication</li></ul><p><strong>6. Build Performance</strong></p><ul><li>Use --profile to see how the gradle build takes place and where most of the time is being spent when building an apk</li><li>Use <a href="https://plugins.gradle.org/plugin/com.gradle.build-scan">build-scan</a> plugin</li><li>Have multiple environment configs for dev and CI</li></ul><p><strong>7. Don’t Use Gradle</strong></p><ul><li>Use <a href="https://github.com/uber/okbuck">okbuck</a> by Uber</li><li>Buck build system is based on Gradle but it is faster and more efficient</li></ul><h3><a href="https://speakerdeck.com/anupcowkur/the-mutable-state-monster-and-how-to-defeat-it">The Mutable State Monster and How to Defeat it.</a></h3><p><em>Anup Cowkur, GO-JEK</em></p><p>Next up after the morning tea break was Anup who gave a talk on Mutable states and how to handle them using excellent references from <em>Lord Of the Rings</em>!!</p><ul><li>A state is simply the value of the data at any point during the execution of the program and it should be consistent in a multi-threaded environment</li><li>He briefly went through 4 sample programs explaining Check-Then-Act, Read-Modify-Write, Visibility problem and Ordering Problem. He went on to show how these could be “fixed” by using synchronized or volatile keywords.</li><li>But Synchronization is hard and complex. So we turn towards <em>functional programming.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BD2pgYjldmplBU4S-oBA4w.png" /></figure><ul><li><em>Referential transparency</em> simply means no difference between value and reference to data. To achieve this, we need immutability for the data</li><li><em>Immutability </em>means that data once created cannot be modified</li><li>Since data cannot be modified, the application doesn’t leave inconsistent data and hence doesn’t affect the original data set.</li><li>Using immutable objects means there is a heavy load on the GC. So use it only when there is a possibility for concurrency.</li><li>Using Java 8 features like Lambdas, Method References etc along with Rx to transform data would be of great help in dealing with mutable state monsters.</li><li><a href="http://kotlinlang.org/">Kotlin</a> (the new kid on the block from IntelliJ) has excellent support for immutable data and it should definitely be given a shot.</li></ul><h3><a href="https://speakerdeck.com/ragdroid/rxify-a-simple-spell-for-complex-rxjava-operators">‘Rxify’ — A Simple spell for Complex RxJava Operators</a></h3><p><em>Garima Jain, Fueled</em></p><p>Garima took the stage next. If Anup used LoR references, Garima took us to the mystical and magical lands of Hogwarts. The session was informative and there are <a href="https://medium.com/@ragdroid/rxify-a-simple-spell-for-complex-rxjava-operators-part-1-4c31921583c4#.xjmjf93fv">medium posts</a> by her on this topic. Some points that were discussed during the talk were,</p><ul><li>Rx (Reactive Extensions) provides us the way to use Observer pattern for sequence of data/events</li><li>Need not worry about thread synchronization, background processing or low-level threading</li><li>Rx has 3 basic elements</li><li><a href="http://reactivex.io/RxJava/javadoc/rx/Observable.html">Observable </a>— produces the items (See the JavaDoc linked for Marble Diagrams on how each Observable works)</li><li>Subscriber — Consumes the items produced by Observable</li><li>Action — Observable calls Action methods like onNext(), onComplete() or onError() to produce data/state</li><li>RxJava has Func1 and Func2 as Actions whereas, in RxJava2, they are named as Function and BiFunction</li></ul><p>This looks a lot like <a href="http://en.wikipedia.org/wiki/Observer_pattern">standard observer pattern</a>, but it differs in one key way — Observable often don&#39;t start producing items until someone explicitly subscribes to them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EmI2b6AQ3M5Vsk6hDXqv2g.png" /></figure><ul><li>Observable.just(…) — to produce a number of items</li><li>Observable.from(T[] array) — to produce items from an array of items</li><li>Observable.map() — transform every item produced by applying a function on each of the items</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_4tchPT5Yara4i6JHYrYsg.png" /></figure><ul><li>Observable.flatMap() — transform every element of collection into another collection and then finally returns the combined collection</li><li>Observable.filter() — filter the original collection to produce only the elements that satisfy the filter criteria</li><li>Observable.zip() — Combine multiple collections together based on a function and produces the result of each combination</li><li>Observable.concat() — Combines two observables into a single Observable without caring about the emitting order</li><li>Observable.merge() — Same as concat() except that this method combines the emitted elements based on their emitted order</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0UJgDOHtZ0kisfXhMXOq8A.png" /></figure><p>BackPressure — When producer produces more elements than the consumer can consume. RxJava2 provides Flowable to handle Back Pressure.</p><ul><li>buffer() — Buffers small chunk of data and produces them together instead of producing one data at a time. This is a loss-less way of handling Backpressure.</li><li>debounce() — It emits an item from the producer only when a particular time has passed since it emitted the previous item. This is a lossy way of handling Backpressure but it is useful in scenarios where constant updates are not required and it is okay to omit a few items</li><li>repeat() — emits the same item again once the previous item is successfully emitted.</li><li>retry() — emits the same item again when there is an error in emitting it previously.</li></ul><h3><a href="https://speakerdeck.com/manaschaudhari/functional-mvvm-using-rxjava-and-data-binding">Functional MVVM Using RxJava and Android Data Binding</a></h3><p><em>Manas Chaudhari, TinyOwl</em></p><ul><li>MVVM stands for Model-View-ViewModel</li><li>The user interface of an application has a lot of changing states, responses from network requests, modifying the UI elements based on the user actions etc.</li><li>For a simple application, the Android way of doing things generate a lot of boilerplate code and the code becomes harder to test.</li><li>RxJava and Android’s Data Binding provides ways around the boilerplate code generation</li><li>Data Binding reduces the need for findViewById() methods and allows us to specify the UI logic inside the XML layout files itself.</li><li>The XML layout is bound to a ViewModel class which has fields linked to the View elements</li><li>Java is basically an Imperative language and RxJava provides the Reactive support for Java by providing Observable and Actions</li><li>RxJava can be used with <a href="https://github.com/JakeWharton/RxBinding">RxBinding</a> from Jake Wharton. This provides ready-made support for text listeners, click listeners etc and hence the XML can be bound to the ViewModel class</li><li>But RxJava uses subscribers and hence they need to be cleaned-up on application destroy so that memory will be released for other apps. Hence the RxJava produces some boilerplate code too</li><li>Data Binding can be used as an alternative for this scenario</li><li>Android Data binding provides ObservableField to communicate with the view. This ObservableField could be converted to Observable (from RxJAVA) and vice versa.</li><li>Converters can be created to convert the Observable to ObservableField or an ObservableField to Observable depending on the need.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m6iezNo8agMIN8BhK1ToVQ.png" /></figure><ul><li>Since the view is updated from ObservableField, there is no need for Subscription. Hence memory leaks would be handled properly</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*llhc0k_IIqD6RbiEuPql4g.png" /></figure><ul><li>Multiple Views can share a single ViewModel and hence MVVM architecture helps in cleaner code</li><li>Layout for adapters could be set using Custom Attributes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iT3_WY5la3Ns-EzulBhYzA.png" /></figure><ul><li>To write the business logic from ViewModel and to give navigation between activities on certain events of a view, interfaces could be used.</li><li>The code is much cleaner and can be unit tested easily.</li></ul><h3><a href="https://docs.google.com/presentation/d/1bM2_8fpuCP7dDr6G4Iu6C1OPURgbbY2c_m-QN9ugbOc/edit#slide=id.p">Jack, Jill and Java 8</a></h3><p><em>Chaitanya Nettem, Self-Employed</em></p><p>Next up was a crisp talk from Chaitanya on the new Java 8 Language features introduced in Android N. His session was informative and if you are starting a new project, make sure it is with Java 8</p><ul><li>JACK — Java Android Compiler Kit</li><li>JILL — Jack Intermediate Library Linker</li><li>JACK is already the default way for compiling AOSP. So if you are a ROM builder, you might probably have worked with JACK</li><li>As of now, Lambdas and Method References are backported to non-Nougat devices. The cooler Stream APIs, Functional Interfaces, Default and static interface methods are limited to Nougat (API 24) and above</li><li>JACK directly converts the java files to dx file while previous Android build process includes usage of javac, progaurd,jacoco etc to convert java files to bytecode. Then it is converted to dex files.</li><li>JILL is used to convert 3rd party libraries/sources to JACK format.</li><li>To enable Java 8 features, add jackOptions to your build.gradle</li></ul><pre><strong>jackOptions</strong> {<br>    enabled true<br>}</pre><pre><strong>compileOptions</strong> {<br>    Sourcecompatibility JavaVersion.VERSION_1_8<br>    targetcompatibility JavaVersion.VERSION_1_8<br>}</pre><ul><li>Jack takes care of all the shrinking, obfuscation etc and hence you do not need Proguard anymore.</li><li>Instant run support is not yet supported :(</li><li>Build generation will take up more time than without Java 8</li><li>Lambdas are just syntactic sugar for now in API &lt;= 23. Internally, they are converted to Anonymous inner classes</li></ul><h3><a href="https://speakerdeck.com/adnan321/droidcon-india-2016-rebuilding-indias-largest-entertainment-app">Rebuilding BookMyShow For Scalability &amp; Maintenance</a></h3><p><em>Adnan A M, BookMyShow</em></p><p>Adnan took the stage. He represented BookMyShow and showed us how they have re-engineered their Android app ground up. Some of the information that he shared are,</p><ul><li>It took them 8 developers, 3,00,000 LOC and 180 days to develop the app</li><li>Follow naming conventions throughout the product. It will be useful when the product is developed by a number of developers together</li><li>Write reusable and modular code.</li><li>Avoid using tightly coupled logic. Use an architecture like MVP or MVVM to split the UI from business logic</li><li>Avoid Redundant code. Having a single class for making all API requests would be great than replicating the UrlConnection code everywhere. That way, it will be easier to make some changes to connection params for all API calls</li><li>A/B testing is not possible without a clear code with clean architecture</li><li>BookMyShow’s new app uses MVP architecture. Though he goes on to say that they have made some relaxations and have used MVP more as a design pattern than an architecture</li><li>Write code that could be used anywhere without modifications. He gave an example of Rating bar which has the same action everywhere. So it is better to reuse the components rather than creating it everywhere</li><li>Normal developers usually follow a packaging order where all the activities are kept under “activity” package, adapters under “adapter” package and so on. This will give rise to a lot of problems and hence he suggests that the java files be split based on their functionality rather than the type of the class</li><li>Create standalone modules which will not get changed often. Networking wrappers, Analytics wrappers could go as separate projects that are included using gradle dependencies.</li><li>Always have a wrapper over the Networking classes and use those wrappers from the classes and not the networking library’s code. Even if in future, the networking library is changed, it could be done independently in the separate project without affecting the application.</li><li>Self-sufficient views are those which have their actions specified already. Rating bar is one such example where its action is to give ratings irrespective of their position. They have accomplished it using a ViewProvider</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N15TKlEx6a7t29VFA1kTmA.png" /></figure><ul><li>Create Human readable API request Builders — This enables the developers who are new to the project get started without the need to worry about the API details such as params, call method etc.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VI90hX7GBW2HV9wwqGjGSw.png" /></figure><ul><li>He then went on to speak about embracing Generic and specific naming conventions for dimens resources. The way he suggested reduces the duplicated resources and ease of maintenance.</li></ul><h3><a href="https://speakerdeck.com/elvisds/crafting-the-perfect-mainactivity">Crafting the Perfect MainActivity</a></h3><p><em>Elvis D’Souza, Sensara</em></p><p>Elvis took the Diaz after a brief tea break. He explained how important the MainActivity of the app is, and how the <em>Sensy Remote app</em> tackled the problem.</p><ul><li>He took examples from Vodafone app, Oneplus Warranty app, Uber and other such apps to show how well they offer their products in the MainActivity for the users.</li><li>MainActivity should impress people and help them to get things done then and there</li><li>A proper landing page will directly affect the UX and revenue for the app</li><li>Images and Video trump text. We perceive images faster than the text</li><li>Understanding the UI will be better if related items are grouped together meaningfully</li><li>Understanding the customer’s needs is vital and the UI should guide them to do their favorite action easily and faster</li><li>Give options to the user to select what should be featured on their home page. Given the sense of ownership, users tend to interact more with the home screen.</li><li>Respect the user’s choices, get the community opinion and craft the MainActivity in such a way that it reflects all the above</li><li>Have meaningful triggers in MainActivity to remind users to perform some tasks</li><li>Do not ask questions that you already know the answer for. Keep track of the user’s common usage and adapt to it</li><li>Priming/On-boarding/Help screens are important. Teach the user what the app is and how it works before they set to work. Keep in mind that users might skip the tutorials/Play Store description etc.</li></ul><p>Well, That’s it for now. We left Day 1 of the DroidCon (10th November 2016) with a handful of goodies and lots of information to process. Stay tuned to know what happened in the Day 2 :)</p><p>UPDATE: Day 2 Experience is live. If you enjoyed this article be sure to head over here for more tech stuff</p><p><a href="https://vivekc.xyz/what-happened-at-droidconin-day-2-ed7d656195c2">What Happened at DroidConIN — Day 2</a></p><p>Ciao</p><p><em>P.S: All the images are taken from the slides of the respective speaker. Click on the title to view the slides.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c26a9d0eb7c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adventurous-android/experience-at-droidconin-2016-9c26a9d0eb7c">What Happened at DroidConIN 2016 — Day 1</a> was originally published in <a href="https://medium.com/adventurous-android">Adventurous Android</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding Chrome OS support to Android Apps]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/adventurous-android/adding-chrome-os-support-to-android-apps-7b0d4d38639b?source=rss----cd32bf3b7535---4"><img src="https://cdn-images-1.medium.com/max/2600/1*xdRq8ucn4JfYSEZYL7fFBQ.png" width="2708"></a></p><p class="medium-feed-snippet">In the last Google I/O, We were quite thrilled to find out that Google will be adding Android apps support for Chrome OS. If you have&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/adventurous-android/adding-chrome-os-support-to-android-apps-7b0d4d38639b?source=rss----cd32bf3b7535---4">Continue reading on Adventurous Android »</a></p></div>]]></description>
            <link>https://medium.com/adventurous-android/adding-chrome-os-support-to-android-apps-7b0d4d38639b?source=rss----cd32bf3b7535---4</link>
            <guid isPermaLink="false">https://medium.com/p/7b0d4d38639b</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[chrome-os]]></category>
            <category><![CDATA[chromebook]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Vivek Chanddru]]></dc:creator>
            <pubDate>Thu, 20 Oct 2016 17:57:55 GMT</pubDate>
            <atom:updated>2016-10-20T18:12:27.478Z</atom:updated>
        </item>
    </channel>
</rss>