Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Mobile / Android

Android User Interactivity, Reponse Time and Sensors

4.65/5 (5 votes)
7 Nov 2014CPOL4 min read 13.1K  
What a user expects

Introduction

Mobile users are impatient and don't hold any loyalty towards apps especially those that they do not use frequently as they can uninstall your app from their device in a blink of an eye, yet you have spent all you have to make it a working app. Users range from individual users, business users, clients, etc.

All these have expectations, qualities that they expect your application to address which may be realistic or unrealistic but always remember clients/users know more than you do therefore you have to ensure you satisfy them and keep the designing standard.

Background

As a developer, I have personally used the common apps on smartphones, for example social media apps, contact management apps, etc. but this is what I found out: All these apps have a common way of designing Interfaces like icon, widgets, notifications, gestures. For example, if you see a gearwheel, you’ll be sure it means ‘settings’. If you see an icon of a trash bin, it will be ‘delete’. Then why not follow these standards in your application because the user is already accustomed to them.

Using the Code

As a developer, you should always be user centrix because your users will not take anything for granted when it comes to their interactivity with your app. Therefore ensure you never take anything for granted like how to use colors, icons, widgets, response time of your app. This should be a major concern to you than even your users.

I am going to illustrate some of the things that you should avoid to ensure a good user interactivity with your application basing on these factors:

  • Gestures
  • Widgets
  • Motion and position
  • Keyboard
  • GPS
  • Environmental Sensors

Gestures

Android is user centered giving users a lot of functionality and customization rights. As new upgrades of the Android Os are realized, they are shipped with more functionalities which include gesture and a lot more.

Below are some of the gestures made by users on their services:

  • Touch/click
  • Tap
  • Hover

Some of these gestures are supported in only certain versions of Android. Hovering is supported only in devices with an Android API Level of 11 and above. For developers, the Android 3.0 platform ( HONEYCOMB).

Android being an opensource Operating system, you as a developer are able to use all the inbuilt Android frameworks, themes, designs in your app and ensure you follow the designing guidelines by Android http://developer.android.com/design/index.html.

How to respond to these different events varies depending on how many events you are responding to. Typically, if you are to respond to only one user gesture/event, then you would use this code:

Java
package com.code256.uilayouts_controls;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class RelativeActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //getting reference to the layout
        setContentView(R.layout.relativelayout);
        //it's advisable to have this in the oncreate method 
        //so that whenever the activity loads it can also load the references
        //getting e reference to the button
        Button button = (Button) findViewById(R.id.btnreg);
        //after getting reference to the button then we can decide 
        //what action to perform when the clicks on the button for example 
        //we would love if the user clicks it takes back to the previous activity
    button.setOnClickListener(new OnClickListener() {
        
        @Override
        public void onClick(View v) {
            // Inner class event handler, when a user clicks on this button then the activity stops
            finish();
        }
    });    
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}

This is how you respond to the hover gesture/event, but this is only supported in Android 3.0 (Honey comb) and above all other gestures that include touch, longpress have the same implementation of responding to user events.

Java
button.setOnHoverListener(new OnHoverListener() {

    @Override
    public boolean onHover(View v, MotionEvent event) {
        // TODO Auto-generated method stub
        return false;
    }
});

It's only the ListView that has a special consideration while responding to the user's event like when a user clicks on a row in the list.

Java
    ListView list = (ListView) findViewById(R.id.list);
list.setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
        // do something when a row is tapped
        
    }
});

Since Mobile devices are limited in terms of battery life, CPU power therefore as we use certain functionality in app development; you have to put into consideration of certain aspects in order not to make your application drain the limited resource of the user's device.

Certain Android services and functionality really drain the limited resources of the user's device like GPS, Location listeners.

Location Listeners/GPS

They are several ways of using GPS and getting the location of the user using the inbuilt services in the Android framework but of these ways, they are methods that drain the resources while others use less of these resources.

For example, if you are requesting for GPS location, there are two methods that you can use that include getLastKnownLocation which returns the last known GPS location saved by the user's device as this will reduce on workload of the device's resource since it will use this the last known location coordinates than requesting for these coordinates every time the app is launched.

Java
//recommended and saves user battery
locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

//uses a lot of user's battery and other resources              

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30000L, 100F, this);

Response Time

This is a crucial factor, no user would like it if your app took more than 10 seconds to respond to an event; this can be boring forcing your app to be uninstalled by the unsatisfied user.

Well, these scenarios can't be avoided but giving the user the right feedback is most important to keep their attention and patience; one of the mostly used techniques is the progress/status bar that runs in the background process for example if you are getting data from a remote database, cloud service name it, you would use one of the inbuilt progress/status bar.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)