Posts

Showing posts from 2013

Check whether network is available on Android phone.

Check the network in android using this function In some Android applications, they can be run properly once the network on device is enable. Or, Android developers want to check the network status before proceed. The simple code snippet I will show today is so simple but sometime it will take you a little bit of time to find/research.  This routine was run and tested as well on  Android 2.2 (API 8)  /** * Checks whether the network is available on Android device. * If the network signal is very low, it will be evaluated as NOT available. * This routine will check both MOBILE and WIFI signal. * If both of them are in disable status, <code>false</code> will be return absolutely. * </p> * Return <code>true</code> if the network is available. Otherwise, return <code>false</code>. * </p> * * @param ctx Context. * * @return <code>True</code> : the network is available.</br> * ...

Android 5.0 (Lollipop)

Image
Android-5.0 (Lollipop) Much of Lollipop's accessibility features are unchanged from KitKat, but there are a few new bits inside The features In one handy list, here's an overview of everything you'll find in the Lollipop accessibility menu. The old and the not so old. Services Talkback:  Google Talkback will give you verbal, audio, and vibration cues by acting as a built-in screen reader. It's perfect for the visually impaired and can be activated with ease from inside the accessibility menu. For more on Google Talkback check out our complete guide  here Switch Access : A new addition for Lollipop, it allows you to configure hard buttons to perform certain tasks to enable better navigation for the visually impaired and makes a pretty powerful tool when paired up with Talkback. System Captions:  Enables the system wide closed caption system for videos. Having been introduced in KitKat it's still pos...

Threading in Android

Image
A Thread is a sequence of instructions executed in order. Although each CPU can proc- ess only one instruction at a time, most operating systems are capable of handling multiple threads on multiple CPUs, or interleaving them on a single CPU. Different threads need different priorities, so the operating system determines how much time to give each one if they have to share a CPU. The Android operating system is based on Linux and as such is fully capable of running multiple threads at the same time. However, you need to be aware of how applications use threads in order to design your application properly. Single Thread By default, an Android application runs on a single thread. Single-threaded applications run all commands serially, meaning the next command is not completed until the pre- vious one is done. Another way of saying this is that each call is blocking . This single thread is also known as the UI thread because it's the thread that processes all the use...

View Flow for Android

Image
In a project I’m currently working on we had the need of scrolling through a bunch of views in a horizontal fashion. I wanted the ViewGroup to be backed up with an Adapter, pretty much like the ListView does it. In my case, the items were to be populated from an online data source. I did find a few different takes on a view switcher but none of them were backed with an Adapter. So I decided to base my work on one of them, but instead extend the AdapterView class in the Android SDK (instead of simply the ViewGroup ). If you’ve implemented a ListView you’ve probably already come across the Adapter concept. An Adapter in Android is more or less a collection of elements of some sort. The Adapter is capable of providing views for each of the elements when asked to. A Listview does, of course, not load a View for each of the elements in the Adapter at once. That would be completly irresponsible as it would eat up the memory in no-time. Instead it loads the view for each element ...

StaggeredGridView Example

Image
Introduction The StaggeredGridView allows the user to create a GridView with uneven rows similar to how Pinterest looks. Includes own OnItemClickListener and OnItemLongClickListener, selector, and fixed position restore. Setup To use StaggeredGridView in your projects, simply add this project to your workspace then add it as a library project to your current project. Usage Attributes supported (same behavior as GridView):  numColumns : determines the amount of columns to be drawn drawSelectorOnTop : determine if selector should be drawn on top <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:staggered="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/mainLayout"> <com.origamilabs.library.views.StaggeredGridView> android:id=...

Use Of Parse.com

Introduction    The Parse platform provides a complete back end solution for your mobile application. Apps  Storing data on Parse is built around the   ParseObject . Each   ParseObject   contains key-value pairs of JSON-compatible data. This data is schemaless, which means that you don't need to specify ahead of time what keys exist on each   ParseObject . You simply set whatever key-value pairs you want, and our backend will store it. Parse.com Link : https://parse.com/docs/android_guide