| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Android example source code file (

This example Android source code file ( is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Android by Example" TM.

Java - Android tags/keywords

activity, android, app, application, arraylist, gesture, gesturelibrary, gestureoverlayview, gesturesactivity, ongestureperformedlistener, os, override, prediction, ui

The Android example source code


import java.util.ArrayList;

import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.Prediction;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.os.Bundle;
import android.widget.Toast;

public class GesturesActivity extends Activity implements OnGesturePerformedListener {
    private GestureLibrary mLibrary;

    public void onCreate(Bundle savedInstanceState) {

        mLibrary = GestureLibraries.fromRawResource(this, R.raw.spells);
        if (!mLibrary.load()) {

        GestureOverlayView gestures = (GestureOverlayView) findViewById(;
	public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
		ArrayList<Prediction> predictions = mLibrary.recognize(gesture);

		// We want at least one prediction
		if (predictions.size() > 0) {
			Prediction prediction = predictions.get(0);
			// We want at least some confidence in the result
			if (prediction.score > 1.0) {
				// Show the spell
				Toast.makeText(this,, Toast.LENGTH_SHORT).show();

Other Android examples (source code examples)

Here is a short list of links related to this Android source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.