Understanding Android Started and Bound Services

In Android, a Service is an application component that can perform long-running operations in the background on the UI thread. By background, it means that it doesn’t have a user interface. A Service runs on the main thread of the calling Component’s process by default (and hence can degrade responsiveness and cause ANRs), hence you should create a new Thread to perform long running operations. A Service can also be made to run in a completely different process.

Continue reading “Understanding Android Started and Bound Services”

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 ListView (Scrolling ViewGroup) Hide/Disable Scrollbars

In Android, if you’ve ever wanted to sort of disable the scrollbars of a scrolling ViewGroup like a ListView, GridView, ScrollView, etc. then there are a few tricks to do that. I’ve tried to compile a set of such tricks to disable (or just hide) scrollbars for such scrolling View Groups.

Continue reading “Android ListView (Scrolling ViewGroup) Hide/Disable Scrollbars”

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)”

Android Contain ListView (Without Scrollbars) In a ScrollView With Other Views

When a ListView is put inside a ScrollView with (or without) other views it takes as much space is available in the ScrollView. So let’s say there are three elements like this:

Continue reading “Android Contain ListView (Without Scrollbars) In a ScrollView With Other Views”

Android Push Notifications with Parse.com

Update: Parse is shutting down. So you should start migrating.

If you want to send messages upstream and downstream from your Parse backend to your app and vice-versa then thankfully Parse does allow you to do that. Parse allows you to send unlimited push notifications to 1 million unique recipients (devices). Then they charge $0.05 per 1000 recipients extra. That’s awesome!

Continue reading “Android Push Notifications with Parse.com”

Android Push Notifications with PubNub Data Streams (via GCM)

PubNub is a SaaS platform that lets us build realtime applications fairly quick by taking implementing websockets and a neat pub/sub API based model along with several other nice features. It’s supported across all sorts of platforms that you can think of like PHP, Ruby, Python, Android, iOS, Java, embedded systems, etc. I’ve covered how to setup it’s Android SDK and the basic usage before. In this tutorial I’d like to cover how we can use it to send Push Notifications via its own REST APIs as well as Google Cloud Messaging (GCM). I’ve already covered Android messaging (showing up as Notifications) via GCM before.

Continue reading “Android Push Notifications with PubNub Data Streams (via GCM)”