Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7945787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:58:37+00:00 2026-06-04T00:58:37+00:00

public class TestActivity extends Activity implements OnGesturePerformedListener { /** Called when the activity is

  • 0
public class TestActivity extends Activity implements OnGesturePerformedListener {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);

    GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestureOverlayView1);
    gestures.addOnGesturePerformedListener(TestActivity.this);

}

My main.xml

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:src="@drawable/ic_launcher" />

<android.gesture.GestureOverlayView
    android:id="@+id/gestureOverlayView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
</android.gesture.GestureOverlayView>

Activity.java:

private GestureLibrary mLibrary;

public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
    ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
    Log.v("performed", "performed");
    // 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) {
            if (prediction.name.equalsIgnoreCase("right swipe")) {
                // do you thing here//
                Toast.makeText(TestActivity.this, "rigth",
                        Toast.LENGTH_SHORT);
            } else if (prediction.name.equalsIgnoreCase("left swipe")) {

                Toast.makeText(TestActivity.this, "lef",
                        Toast.LENGTH_SHORT);
            }
        }
    }
}

Running this crashes with the following in Log:

05-17 15:18:52.124: E/AndroidRuntime(17266): FATAL EXCEPTION: main
05-17 15:18:52.124: E/AndroidRuntime(17266): java.lang.RuntimeException: Unable to start activity ComponentInfo{t.e.st/t.e.st.TestActivity}: java.lang.NullPointerException
05-17 15:18:52.124: E/AndroidRuntime(17266):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at android.app.ActivityThread.access$1500(ActivityThread.java:123)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at android.os.Looper.loop(Looper.java:130)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at android.app.ActivityThread.main(ActivityThread.java:3835)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at java.lang.reflect.Method.invokeNative(Native Method)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at java.lang.reflect.Method.invoke(Method.java:507)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at dalvik.system.NativeStart.main(Native Method)
05-17 15:18:52.124: E/AndroidRuntime(17266): Caused by: java.lang.NullPointerException
**05-17 15:18:52.124: E/AndroidRuntime(17266):  at t.e.st.TestActivity.onCreate(TestActivity.java:26)**
05-17 15:18:52.124: E/AndroidRuntime(17266):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-17 15:18:52.124: E/AndroidRuntime(17266):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
05-17 15:18:52.124: E/AndroidRuntime(17266):    ... 11 more

Please help me solve this.

The Overlay is there in xml. so thats not the issue and its says the error is in line 26. So its abt addOnGesturePerformedListener();

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:58:39+00:00Added an answer on June 4, 2026 at 12:58 am

    if you are sure you have a View with @+id = "gestureOverlayView1" inside your main.xml layout, then try

    gestures.addOnGesturePerformedListener(this); 
    

    instead of

    gestures.addOnGesturePerformedListener(TestActivity.this);
    

    (remove the TestActivity specifier from this)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class TestActivity extends Activity { public static TestActivity mTestActivity; @Override public void onCreate(Bundle
public class Offer_Popup extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.offer_popup); //newly
public class MyClass { public int Age; public int ID; } public void MyMethod()
public class Test { public static void main(String[] args) { } } class Outer
public class doublePrecision { public static void main(String[] args) { double total = 0;
public class WrapperTest { static { print(10); } static void print(int x) { System.out.println(x);
public class WrapperTest { public static void main(String[] args) { Integer i = 100;
I have a custom view called DrawView created in the main activity. I have
My code is : public class EventDataSQLHelper extends SQLiteOpenHelper { private static final String
public class PackageTabActivity extends ListActivity{ HashMap<String,Object> hm ; ArrayList<HashMap<String,Object>> applistwithicon ; private static final

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.