An Android application will often need to have a dedicated section (page/Activity) where the user should be able to modify the app settings like enable/disable notifications, backup and sync data with cloud, etc. or changing preferences that’ll make the app behave differently because of various contexts you set like your name, profile pic, gender, birth date, etc. This also allows the app to dynamically generate the UI with the contextual details as well as use them for other purposes like “show me offers between $10-$100 only” or “I want to see people aged 15-25”. To achieve this, either you can definitely build your own set of Activities and layouts and manage a lot of the backend operations like CRUD all by yourself or use the Preference API to quickly build an interface that has the same look and feel as the System Settings app where you go to change all your phone settings.
Category: Mobile Development
Android Debug Bridge (adb) Wireless Debugging Over Wi-Fi
We mostly connect our Android device to our computers with a USB cable for debugging purposes. It is possible to use adb over a wifi connection than a USB to save some wire-related hassles in our lives. The process is super simple, let’s go through it quickly.
Continue reading “Android Debug Bridge (adb) Wireless Debugging Over Wi-Fi”
Android/Java Multi-Threaded Execution with the Executor Framework (ThreadPoolExecutor)
These days CPUs with multiple cores have almost become the standard in Android devices. This means multiple operations (could be long running and resource intensive tasks) doesn’t have to wait to be executed on a single thread. They can rather run on multiple threads in parallel where each threads gets executed on a single processor. For example imagine an operation where multiple images have to be downloaded and shown in a gallery view. The downloads and any decoding required for different images could happen concurrently on multiple threads speeding up the entire operation, leading to a faster app experience.
Difference Between setDisplayHomeAsUpEnabled(), setHomeButtonEnabled() and setDisplayShowHomeEnabled() ActionBar Methods in Android
The Android ActionBar has a couple of methods that can get a little confusing at times as to what their purpose is:
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)”
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 Sharing Application Data with Content Provider and Content Resolver
In the previous article (must read) we discussed how basic CRUD operations can be done on SQLite in Android. An SQLite database is inherently private to the application that creates it. That means if you want some other app to access your data that won’t be possible. To solve this limitation (its more of a security measure actually), Android has the concept of Content Providers using which one app can give out constrained access to its structured set of data to other apps. So a content provider allows application to access its data which is mostly stored in an SQLite database. It is important to note that just because providers allow you to share data with other applications doesn’t mean that it cannot be used in the same application to access data.
Continue reading “Android Sharing Application Data with Content Provider and Content Resolver”