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 5955327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:05:54+00:00 2026-05-22T18:05:54+00:00

A user submitted the following crash report: java.lang.NullPointerException at android.widget.TextView.onTouchEvent(TextView.java:7202) at android.view.View.dispatchTouchEvent(View.java:3778) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:886)

  • 0

A user submitted the following crash report:

java.lang.NullPointerException
at android.widget.TextView.onTouchEvent(TextView.java:7202)
at android.view.View.dispatchTouchEvent(View.java:3778)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:886)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:886)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:886)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:886)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:886)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1716)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1124)
at android.app.Activity.dispatchTouchEvent(Activity.java:2125)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1700)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1822)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:5068)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)

I can’t reproduce it on any of my test phones (Xperia, HTC Desire, Galaxy S) (or the emulators), and the error report doesn’t tell me where in the app the problem is or on what device (or who the user was so I can ask them for more information about what they were doing that caused it). I can’t find anywhere in the code where I obviously try to use a TextView via findViewById without checking if it’s null first. None of the xml files have android:onclick in them, so it’s not trying to call a mistyped function or something like that. I tried comparing the lines given to the android source, but they don’t seem to match directly, and reading the source of the named methods hasn’t helped me. (Disclaimer: I’ve only been using Java for a couple of months.)

Anyone have any idea what else I should check?


ETA: This is only place I have a touchlistener instead of a clicklistener is here:

btnDelete.setOnTouchListener(new View.OnTouchListener()
{
  public boolean onTouch(View v, MotionEvent meMotion)
  {
    int iAction = meMotion.getAction();

    switch (iAction)
    {
      case MotionEvent.ACTION_DOWN:
        if (false == bKeyPressed)
        {
          bKeyPressed = true;
          deleteANumber();
        }
        mHandler.removeCallbacks(mDeleteTouch);
        mHandler.postAtTime(mDeleteTouch, SystemClock.uptimeMillis()
          + BUTTON_DELAY);
        break;
      case MotionEvent.ACTION_UP:
        bKeyPressed = false;
        mHandler.removeCallbacks(mDeleteTouch);
        break;
    }

    return true;
  }
});

where mDeleteTouch is

private final Runnable mDeleteTouch = new Runnable()
{
  public void run()
  {
    // delete a number from the display
    deleteANumber();

    // then call self in BUTTON_DELAY ms, unless cancelled
    mHandler.postAtTime(this, SystemClock.uptimeMillis() + BUTTON_DELAY);
  }
};

and deleteANumber() is

protected void deleteANumber()
{
  String strNumber = tvNumber.getText().toString();

  // only remove a character if there is at least one:
  if (strNumber.length() > 0)
  {
    strNumber = strNumber.substring(0, strNumber.length() - 1);
    tvNumber.setText(strNumber);
  }
}

which seems like it could be the problem as you can’t call null.length(), but tvNumber is created with its text set to “”, so getText().toString() should always return a non null value, right?


ETA2 I’ve managed to get the same error on an HTC Desire HD, but it seems to crash without going back into my code — setting breakpoints immediately inside the onClick doesn’t catch anything.


ETA3 If I comment out tvNumber.setInputType(InputType.TYPE_CLASS_NUMBER); the problem goes away.

  • 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-05-22T18:05:54+00:00Added an answer on May 22, 2026 at 6:05 pm

    On the HTC Desire HD, touching a TextView with setInputType(InputType.TYPE_CLASS_NUMBER) set appears to throw a NullPointerException. Leaving that setting out prevents the crash, but necessitates manual input filtering (which isn’t a problem in my case, but probably is in other people’s). Not a good solution, but a solution nethertheless.

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

Sidebar

Related Questions

I have a MyTouch 4g user that has submitted the following screenshots (sorry can't
I have some user-submitted variables that I want to display in a different part
I want to extract Urdu phrases out of a user-submitted string in PHP. For
I am working on finding a good way to make user submitted data, in
I have a Flash web app which displays user submitted PNG files. Files are
I'm using PHP's DOMDocument to parse and normalize user-submitted HTML using the loadHTML method
I have an each method that is run on some user-submitted data. Sometimes it
I'm looking for best practices for performing strict (whitelist) validation/filtering of user-submitted HTML. Main
I want a function/code which will return the value that the user submitted for
Is it safe to query with object.get without escaping or validation user submitted value?

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.