Tuesday, December 07, 2010

MonkeyRunner Testing on Android - Kapil Sharma


The android monkeyrunner tool provides an API for writing programs that control an Android device or emulator from outside of Android code. 

With monkeyrunner, you can write a Python program that installs an Android application or test package, runs it, sends keystrokes to it, takes screenshots of its user interface, and stores screenshots on the workstation. 

The monkeyrunner tool is primarily designed to test applications and devices at the functional/framework level and for running unit test suites, but you are free to use it for other purposes.

The monkeyrunner tool is not related to the UI/Application Exerciser Monkey, also known as the monkey tool. The monkey tool runs in an adb shell directly on the device or emulator and generates pseudo-random streams of user and system events. 

In comparison, the monkeyrunner tool controls devices and emulators from a workstation by sending specific commands and events from an API.
The monkeyrunner tool provides these unique features for Android testing:
  • Multiple device control: The monkeyrunner API can apply one or more test suites across multiple devices or emulators. You can physically attach all the devices or start up all the emulators (or both) at once, connect to each one in turn programmatically, and then run one or more tests. You can also start up an emulator configuration programmatically, run one or more tests, and then shut down the emulator.
  • Functional testing: monkeyrunner can run an automated start-to-finish test of an Android application. You provide input values with keystrokes or touch events, and view the results as screenshots.
  • Regression testing - monkeyrunner can test application stability by running an application and comparing its output screenshots to a set of screenshots that are known to be correct.
  • Extensible automation - Since monkeyrunner is an API toolkit, you can develop an entire system of Python-based modules and programs for controlling Android devices. Besides using the monkeyrunner API itself, you can use the standard Python os and subprocess modules to call Android tools such as Android Debug Bridge.
    You can also add your own classes to the monkeyrunner API. This is described in more detail in the section Extending monkeyrunner with plugins.

    The monkeyrunner tool uses Jython, a implementation of Python that uses the Java programming language. Jython allows the monkeyrunner API to interact easily with the Android framework. With Jython you can use Python syntax to access the constants, classes, and methods of the API.

Android 2.3 Official Video

Android 2.3 SDK :

http://developer.android.com/sdk/android-2.3.html

New User Features:
1.) UI refinements for simplicity and speed
2.) Faster, more intuitive text input
3.) One-touch word selection and copy/paste
4.) Improved power management
5.) Control over applications
6.) New ways of communicating, organizing

New Developer Features
1.) Enhancements for gaming
2.) New forms of communication
3.) Rich multimedia

New Platform Technologies
1.) Media Framework
2.) New Linux Kernel
3.) New Dalvik runtime

Tuesday, June 08, 2010


Apps on sdcard -- can't install apps anymore: Tips for installation.

Try this trick:

kash@ubuntu:- /xyz$ adb shell

# cd system/app

# chmod 771 app

# exit

kash@ubuntu:- /xyz$ adb install kash.apk

And the the .apk installed on Android device.


Monday, May 24, 2010

Android Froyo 2.2 SDK release.


Froyo >> 2.2 New SDK

1.) Dalvik JIT, improve CPU performance 2-5 times
2.) V8 JavaScript engine, improve browser JavaScript performance by 2-3 times
3.) 3G tethering via USB and Wifi
4.) New camera UI for controlling zoom, flash, white balance, geo-tagging, focus and exposure.
5.) Microsoft exchange support, incl remote wipe
6.) Bluetooth: share contacts, voice dialing
7.) Android market: app crash/freeze report, auto app update
8.) App2SD
9.) Option for automatic app data backup
10.) Android Cloud to Device Messaging
11.) Supports Macromedia Flash 10.1
12.) Enable/disable data access over Mobile network
13.) Multiple keyboard languages
14.) Voice recognition for 7 dialects of English, Mandarin Chinese, and Japanese
15.) PIN screen lock

Saturday, January 30, 2010


Reading Data from the Database:

There are many ways to read data from an SQL database, but they all come down to a basic sequence of operations:

  1. Create an SQL statement that describes the data that you need to retrieve.

  2. Execute that statement against the database.

  3. Map the resulting SQL data into data structures that the language you're working in can understand.

Saturday, December 19, 2009


On exploring databases on the emulator and available devices:

Many content providers in Android use SQLite databases (http://www.sqlite.org/),
user can use tools provided both by Android and by SQLite to examine the databases.
Many of these tools reside in the \android-sdk-install-directory\tools subdirectory.

One of the tools is a remote shell on the device that allows user to execute a command-line
SQLite tool against a specified database.

Android uses another command-line tool called Android Debug Bridge (adb), which is
available as " tools\adb.exe "

Thursday, November 26, 2009


Android Database:

Android's Java interface to its relational database, SQLite.
It supports an SQL implementation rich enough for anything you're likely to need in a mobile application, including a cursor facility.

ContentProvider:

An interface used between applications.

The server application that hosts the data manages it through basic create, read, update, and delete (CRUD) operations.

The client application uses a similar API, but the Android framework transmits the client's requests to the server.

Wednesday, July 01, 2009


Android Database Design Considerations :

There are main two considerations specific to Android that consider when designing database:

A.)  Files (such as bitmaps or audio fi les) are not usually stored within database tables.
Instead, use a string to store a path to the fi le, preferably a fully qualifi ed Content Provider URI.

B.)  While not strictly a requirement, it’s strongly recommended that all tables include an 
auto-increment key fi eld, to function as a unique index value for each row. 
It’s worth noting that if you plan to share your table using a Content Provider, 
this unique ID fi eld is mandatory.

Opening and Creating Databases without the SQLiteHelper:

You can create and open databases without using the SQLiteHelper class with the 
openOrCreateDatabase method on the application Context.

Setting up a database is a two-step process. 

First, call openOrCreateDatabase to create the new data-base. 
Then, call execSQL on the resulting database instance to run the SQL commands that will create 
your tables and their relationships. 

Using the SQLiteOpenHelper:

SQLiteOpenHelper is an abstract class that wraps up the best practice pattern for creating, opening, and upgrading databases. 

By implementing and using an SQLiteOpenHelper, you hide the logic used to decide if a database needs to be created or upgraded before it’s opened.

The code snippet shows how to extend the SQLiteOpenHelper class by overriding the construc-tor, onCreate, and onUpgrade methods to handle the creation of a new database and upgrading to a new version, respectively. 

Example of use of databse in Android Apps. code:

  public MyObject getEntry(long _rowIndex) {
    MyObject objectInstance = new MyObject();
    // TODO Return a cursor to a row from the database and
    // use the values to populate an instance of MyObject
    return objectInstance;
  }
  public int updateEntry(long _rowIndex, MyObject _myObject) {
    String where = KEY_ID + “=” + _rowIndex;
    ContentValues contentValues = new ContentValues();
    // TODO fill in the ContentValue based on the new object
    return db.update(DATABASE_TABLE, contentValues, where, null);
  }

Android and use of Databases:

Plan to create a database adapter, which adds an abstraction layer that encapsulates database inter - actions. It should provide intuitive, strongly typed methods for adding, removing, and updating items. 

A database adapter should also handle queries and wrap creating, opening, and closing the database.

It’s often also used as a convenient location from which to publish static database constants, including table names, column names, and column indexes.

Wednesday, June 03, 2009

SQLite Cursors and Content Values:

ContentValues objects are used to insert new rows into database tables (and Content Providers). Each Content Values object represents a single row, as a map of column names to values. 
Queries in Android are returned as Cursor objects. Rather than extracting and returning a copy of the result values, Cursors act as pointers to a subset of the underlying data. Cursors are a managed way of controlling your position (row) in the result set of a database query. 

The Cursor class includes several functions to navigate query results including, but not limited to, the following:

moveToFirst >> Moves the cursor to the fi rst row in the query result.

moveToNext >> Moves the cursor to the next row.

moveToPrevious >> Moves the cursor to the previous row.

getCount >> Returns the number of rows in the result set.

getColumnIndexOrThrow >> Returns an index for the column with the specifi ed name (throw-
ing an exception if no column exists with that name).

getColumnName >> Returns the name of the specifi ed column index.

getColumnNames >> Returns a String array of all the column names in the current cursor.

Monday, May 04, 2009

SQLite Database for Data Storage and Retrieval :

Rapid and efficient data storage and retrieval are essential for a device whose storage capacity is limited by its compact nature.

Android provides a lightweight relational database for each application using SQLite.

By default, each application database is sandboxed — its content is available only to the application that created it — but Content Providers supply a mechanism for the managed sharing of these application databases.

Native Google Maps, Geocoding, and Location-Based Services :

Native map support lets you create a range of map-based applications that leverage the mobility of Android devices. Android lets you create activities that include interactive Google Maps as part of your user interface with full access to maps that you can control programmatically and annotate using Android’s rich graphics library.

Android’s location-based services manage technologies like GPS and Google’s GSM cell-based location technology to determine the device’s current position. These services enforce an abstraction from spe-cifi c location-detecting technology and let you specify minimum requirements (e.g., accuracy or cost) rather than choosing a particular technology.

It also means that your location-based applications will work no matter what technology the host handset supports. To combine maps with locations, Android includes an API for forward and reverse geocoding that lets you fi nd map coordinates for an address, and the address of a map position.