Android Interprocess Communication (IPC) with Messenger (Remote Bound Services)

Interprocess Communication is the communication of threads across process boundaries. This type of communication is supported through the binder framework in Android. In the article on Services earlier, we discussed Bound Services that has a client-server interface. A bound service is the server which allows clients (components such as activities) to bind to the Service and then send requests and receive responses. The code we discussed works across threads in the same process but will fail in the case of remote services where the Service is running in a different process altogether.

Continue reading “Android Interprocess Communication (IPC) with Messenger (Remote Bound Services)”

Android Scroll to Top of ScrollView with ListView and Other Child Views (Initial Jump Issue)

In my Android app, I was working in an Activity where I had a ScrollView containing a LinearLayout (could be a RelativeLayout too though) that had a few Views at the top followed by a ListView in the end that was long enough to move out of the bottom edge and add scrollbars to itself. Since I’d set a height to the ListView the ScrollView gained it’s vertical scrollbars.

Continue reading “Android Scroll to Top of ScrollView with ListView and Other Child Views (Initial Jump Issue)”

Understanding Android Intent Filters (Receiving Implicit Intents)

Intents sends signals to the Android system telling it that some action needs to be performed by another component (activity, services, broadcast receivers) in the same app or a different app. The system starts resolving which component in which app is responsible to handle this event that just got triggered. Let’s see a simple example of an implicit intent that opens a webpage URL in the browser.

Continue reading “Understanding Android Intent Filters (Receiving Implicit Intents)”

Understanding Android Broadcast Receivers

A BroadcastReceiver is an Android app component that responds to system-wide broadcast announcements. Imagine an event like external power being connected/disconnected from the device, screen turning on/off, battery getting low or picture captured. All these events originate from the system. Infact apps themselves can also initiate broadcasts – for example the SMS app broadcasting that an SMS has being received and let other apps know about this event so that they can trigger some action. Unlike Activities broadcast receivers do not have any user interface but may create a status bar notification. It is intended to do minimal amount of work and can delegate hardcore jobs to Services. It receives an Intent object, so if you’ve read my previous articles on Intents and Intent Filters you’ll have an easy time learning it.

Continue reading “Understanding Android Broadcast Receivers”

Understanding Explicit and Implicit Android Intents (App Component)

Any android application comprises one or more activities. In order to launch another activity from a particular activity (for example launch RegisterActivity from a click action in LoginActivity) we’ve to use a particular app component that android has called Intent. An Intent is basically an intention to do an action. It’s a way to communicate between Android components (not just activities) to request an action from and by different components. It’s like a message that Android listens for and react accordingly by identifying and invoking the appropriate app’s appropriate component (like an Activity, Service, Content Provider, etc.) within that same application or some other app. If multiple apps are capable of responding to the message then Android provides the user with a list of those apps from which a choice can be made.

Continue reading “Understanding Explicit and Implicit Android Intents (App Component)”

Android PubNub Integration Tutorial (Setup and Basic Publish/Subscribe Usage)

PubNub is a lovely SaaS platform that helps us build realtime applications very fast without coding our own backend infrastructure. It has 60+ SDKs and can be used with JavaScript, Ruby, PHP, iOS, Android, Python, etc. In this specific article, we’ll deal with the Android SDK only. So in my Android application I had to code a small chat piece where multiple people could chat in groups (similar to WhatsApp groups). The idea of this article is to quickly show you how to install the PubNub Android SDK in your app and get started.

Continue reading “Android PubNub Integration Tutorial (Setup and Basic Publish/Subscribe Usage)”