Showing newest 3 of 6 posts from January 2009. Show older posts
Showing newest 3 of 6 posts from January 2009. Show older posts

Wednesday, January 28, 2009

The Web Companion story

At least until the last 2 years (before the Iphone's release), it was very hard to use my WAP based phone and set personal preferences that dictate the experience of the mobile portal i use regularly.

Webcompanion as the name suggests is used as a companion tool to let users set their preferred mobile site experience preferences using a personal computer with a browser (usually better than the Mobile device browser). To support such an easy editable interface the webcompanion was built and typically is hosted by the same company that created the mobile site.

Even though the idea is good it produced little ROI a year ago before the Smart phone revolution started and when most of the devices weren't following any usability standards. A little ROI because very few mobile users are aware of it and preferred setting their preferences using a PC. The smart phones changed the way users can use their device to access the internet and see any mobile site. These devices also came up with smart and simplified input interfaces that the users can comfortably use to customize any supported site preferences.

This brings us to the question whether an investment creating and maintaining the webcompanion serves its purpose at all?

Convergence is a reality in the near future and we may end up removing the term mobile site all together from the tech jargon. Now this makes us ask if mobile site itself is worth the investment? For now, it is because we're not there yet. And even webcompanion will serve its purpose through the users who're still on the legacy (WAP) devices and prefer their computers when they're connected at home. A better way to implement and maintain webcompanion is by hosting on a provider content portal that faces the PC world. This not only reduces the cost of maintenance but also makes use of existing hardware. The webcompanion hosted in this way can also push for a little Ad revenue.

However, the webcompanion has a very short life.

Wednesday, January 7, 2009

Android:- Location Based Services

A mobile device with accurate location awareness is very powerful. Combining location awareness with network data access is world changing – and this is where Android shines. From direct network queries, to triangulation with cell towers, and even the Global Positioning System (GPS), an Android powered device has access to several different LocationProvider instances that it can utilize to access location data. Different providers supply a varied mix of location related metrics including: latitude and longitude, speed, bearing and altitude.

GPS is the most common location provider you will work with on the Android platform, because it is the most accurate and powerful option. Nevertheless, some devices may either not have a GPS receiver, or for one reason or another GPS signal may not be available. In those instances the Android platform provides the capability to fail gracefully - to query other providers when our first choice fails. We can configure which providers are available, and hook into one or another through the LocationManager class.

Location awareness opens up a new world of possibilities for application development. We are just beginning to see what inventive developers can do with real time location information and faster and more reliable network data access.

Accessing location data/ Notification with Android Location Manager

Step 1:
android.location.LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

Step2:
// we assign location provider, In this case we are using GPS (Global Positioning System) provider
android.location.LocationProvider locationProvider = this.locationManager.getProvider(LocationManager.GPS_PROVIDER);

Step3:
Location Related permissions need to be provided in manifest.xml, depending on the providers in use.

// this corresponds to the NETWORK provider (cell and WiFi based data)

// this corresponds to the GPS provider.

Note that Step 2 takes location provider from GPS, adding an extra permission is worthwhile enhancement would be to fall back if the GPS provider is unavailable or disabled.

Step 4:
Creating LocationListener and registration of the Listeners
A) Creation of LocationListener.

private final LocationListener locationListenerData = new LocationListener(){
public void onLocationChanged(final Location loc) {
int lat = (int) (loc.getLatitude() * LocationHelper.MILLION);
int lon = (int) (loc.getLongitude() * LocationHelper.MILLION);
GeoPoint geoPoint = new GeoPoint(lat, lon);
MapViewActivity.this.getBuoyData(geoPoint);
}
public void onProviderDisabled(final String s) { } public void onProviderEnabled(final String s) { }
public void onStatusChanged(final String s, final int i, final Bundle b) { }
};
B) Registering listener to be notified by the named provider.
if (locationProvider != null) {
this.locationManager.requestLocationUpdates( locationProvider.getName(), 3000, 185000, this.locationListenerData);
}


Note: - The time parameter to the requestLocationUpdates method should be used carefully. Getting location updates too frequently can wear down the battery and make the application too “noisy”.

This ends integration of location based notification. We can use the power of GeoPoint and MapView as well to customize views and display.

Location, location, location, as they say in real estate, could also be the mantra for the future of mobile computing. Arguably one of the most important features of the Android platform is the support for readily available location information and the inclusion of smart mapping APIs and other location related utilities.

Common Layouts in Android

In my previous post, the discussion was centered on the basics of Views and View groups. Now shifting the focus to the most commonly used layout objects. The commonly used view groups that are used in most applications are:

  • LinearLayout : When the order of arrangements of widgets/views of the layout needs to be horizontal or vertical manner, the LinearLayout widget comes in handy. The direction of arrangement can be set to horizontal or vertical, default being horizontal.
  • TableLayout : As the name suggests, this layout object is used when the layout has widgets/views that need to be arranged into rows and columns. This is similar to html tables. The cells can span columns. The TableLayout do not display its border. The columns can be made to shrink and stretch by setting the respective properties. TableRow is another helper widget which should be used in conjunction with the TableLayout.
  • RelativeLayout : When the position of each of the widgets/view is in relative/dependent to each other, then a relative layout is used. That is for example, when a layout is needed such that it has a text view just to the left of an Edit Textbox, and a button just below the EditText. The relation between the views are taken care in one iteration, hence if view B’s position is dependent on view A’s position, view A must come first in the layout.
  • FrameLayout : This is a very simply layout which is used to hold a section of the screen blank, for displaying an item or group of items at run time. All the elements added in the framelayout will be added to the top left of the screen.
  • AbsoluteLayout : When there is a need is to specify exact x and y co-ordinate position of the view, then AbsoluteLayout need to be used. This layout should not be used as far as possible as it is difficult to maintain.


There are some other important ViewGroups such as ListView and ScrollView. ListView is used to display list of items in a vertically scrolling list. ListView has many optimizations that are important for large lists. ScrollView is used for vertically scrolling in which an infinite amount of space is given to the container to hold all the elements of the view. A ScrollView should have one child which has the elements to be scrolled. A ScrollView cannot be used in conjunction with a ListView since the list views optimizations will be nullified in effect.

All these above Views/ViewGroups can be customized to create customized widgets for specific requirements. This can be achieved by extending required widgets. The onDraw and onMeasure are the important methods which need to be over-ridden when drawing customized widgets/views. Any layout comprises of a two-pass process. The first pass is the measurement pass after which all the views in the layout have its measurements stored. In the second pass each parent positions their respective children. Both the passes are top-down.

A developer’s challenge is to understand the different layouts and use the correct layout so as to achieve optimal performance. A screen can be laid in different ways in any of the above specified layouts. Developers should decide to use the correct layout as per their requirement. If the view hierarchy is too deep, then there might be stack over flow.

Android provides lots of features for the development of a rich and a user friendly UI. There is a good deal of learning curve involved in developing fairly complex UI Layouts.