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

  • Home
  • SEARCH
  • 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 7041681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:04:32+00:00 2026-05-28T02:04:32+00:00

I have an application where i have a screen with some edit text fields

  • 0

I have an application where i have a screen with some edit text fields and when the user enters data ,then presses the button which does the calculation.
But if i don’t enter data and just press the button,it crashes.

I thought sth like when there is no data, then throw a message but i don’t know how to do that!

Is there another way?

Here is this part.It calls the mass_calcs function which does the calculations.

public void onClick(View v) {
        switch (v.getId()){
        case R.id.mass_calcs:
            mass_func();
            break;
        }

Here is the logcat :

01-08 18:45:25.650: I/jdwp(723): received file descriptor 13 from ADB
01-08 18:45:25.752: W/System.err(723): Can't dispatch DDM chunk 46454154: no handler defined
01-08 18:45:25.752: W/System.err(723): Can't dispatch DDM chunk 4d505251: no handler defined
01-08 18:49:13.350: W/InputMethodManager(723): Ignoring onBind: cur seq=2, given seq=1
01-08 18:49:14.999: W/KeyCharacterMap(723): No keyboard for id 0
01-08 18:49:14.999: W/KeyCharacterMap(723): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
01-08 18:49:15.589: D/AndroidRuntime(723): Shutting down VM
01-08 18:49:15.589: W/dalvikvm(723): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
01-08 18:49:15.599: E/AndroidRuntime(723): Uncaught handler: thread main exiting due to uncaught exception
01-08 18:49:15.692: E/AndroidRuntime(723): java.lang.NumberFormatException: 
01-08 18:49:15.692: E/AndroidRuntime(723):  at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:258)
01-08 18:49:15.692: E/AndroidRuntime(723):  at java.lang.Double.parseDouble(Double.java:323)
01-08 18:49:15.692: E/AndroidRuntime(723):  at com.wordpress.androiddevgeo.Radiation.number_mass.mass_func(number_mass.java:52)
01-08 18:49:15.692: E/AndroidRuntime(723):  at com.wordpress.androiddevgeo.Radiation.number_mass.onClick(number_mass.java:45)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.view.View.performClick(View.java:2179)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.view.View.onTouchEvent(View.java:3828)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.widget.TextView.onTouchEvent(TextView.java:6291)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.view.View.dispatchTouchEvent(View.java:3368)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 18:49:15.692: E/AndroidRuntime(723):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1707)
01-08 18:49:15.692: E/AndroidRuntime(723):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1197)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.app.Activity.dispatchTouchEvent(Activity.java:1993)
01-08 18:49:15.692: E/AndroidRuntime(723):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1691)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1525)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.os.Looper.loop(Looper.java:123)
01-08 18:49:15.692: E/AndroidRuntime(723):  at android.app.ActivityThread.main(ActivityThread.java:3948)
01-08 18:49:15.692: E/AndroidRuntime(723):  at java.lang.reflect.Method.invokeNative(Native Method)
01-08 18:49:15.692: E/AndroidRuntime(723):  at java.lang.reflect.Method.invoke(Method.java:521)
01-08 18:49:15.692: E/AndroidRuntime(723):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
01-08 18:49:15.692: E/AndroidRuntime(723):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
01-08 18:49:15.692: E/AndroidRuntime(723):  at dalvik.system.NativeStart.main(Native Method)
01-08 18:49:15.799: I/dalvikvm(723): threadid=7: reacting to signal 3
01-08 18:49:16.030: I/dalvikvm(723): Wrote stack trace to '/data/anr/traces.txt'
01-08 18:49:19.361: I/Process(723): Sending signal. PID: 723 SIG: 9
01-08 19:15:31.900: D/AndroidRuntime(767): Shutting down VM
01-08 19:15:31.900: W/dalvikvm(767): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
01-08 19:15:31.900: E/AndroidRuntime(767): Uncaught handler: thread main exiting due to uncaught exception
01-08 19:15:31.954: E/AndroidRuntime(767): java.lang.NumberFormatException: 
01-08 19:15:31.954: E/AndroidRuntime(767):  at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:258)
01-08 19:15:31.954: E/AndroidRuntime(767):  at java.lang.Double.parseDouble(Double.java:323)
01-08 19:15:31.954: E/AndroidRuntime(767):  at com.wordpress.androiddevgeo.Radiation.number_mass.mass_func(number_mass.java:51)
01-08 19:15:31.954: E/AndroidRuntime(767):  at com.wordpress.androiddevgeo.Radiation.number_mass.onClick(number_mass.java:45)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.view.View.performClick(View.java:2179)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.view.View.onTouchEvent(View.java:3828)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.widget.TextView.onTouchEvent(TextView.java:6291)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.view.View.dispatchTouchEvent(View.java:3368)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 19:15:31.954: E/AndroidRuntime(767):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1707)
01-08 19:15:31.954: E/AndroidRuntime(767):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1197)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.app.Activity.dispatchTouchEvent(Activity.java:1993)
01-08 19:15:31.954: E/AndroidRuntime(767):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1691)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1525)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.os.Looper.loop(Looper.java:123)
01-08 19:15:31.954: E/AndroidRuntime(767):  at android.app.ActivityThread.main(ActivityThread.java:3948)
01-08 19:15:31.954: E/AndroidRuntime(767):  at java.lang.reflect.Method.invokeNative(Native Method)
01-08 19:15:31.954: E/AndroidRuntime(767):  at java.lang.reflect.Method.invoke(Method.java:521)
01-08 19:15:31.954: E/AndroidRuntime(767):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
01-08 19:15:31.954: E/AndroidRuntime(767):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
01-08 19:15:31.954: E/AndroidRuntime(767):  at dalvik.system.NativeStart.main(Native Method)
01-08 19:15:32.021: I/dalvikvm(767): threadid=7: reacting to signal 3
01-08 19:15:32.259: I/dalvikvm(767): Wrote stack trace to '/data/anr/traces.txt'
01-08 19:15:34.082: I/Process(767): Sending signal. PID: 767 SIG: 9
01-08 19:16:41.569: W/KeyCharacterMap(774): No keyboard for id 0
01-08 19:16:41.582: W/KeyCharacterMap(774): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
01-08 19:16:45.840: D/AndroidRuntime(774): Shutting down VM
01-08 19:16:45.840: W/dalvikvm(774): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
01-08 19:16:45.840: E/AndroidRuntime(774): Uncaught handler: thread main exiting due to uncaught exception
01-08 19:16:45.911: E/AndroidRuntime(774): java.lang.NumberFormatException: 
01-08 19:16:45.911: E/AndroidRuntime(774):  at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:258)
01-08 19:16:45.911: E/AndroidRuntime(774):  at java.lang.Double.parseDouble(Double.java:323)
01-08 19:16:45.911: E/AndroidRuntime(774):  at com.wordpress.androiddevgeo.Radiation.number_mass.mass_func(number_mass.java:51)
01-08 19:16:45.911: E/AndroidRuntime(774):  at com.wordpress.androiddevgeo.Radiation.number_mass.onClick(number_mass.java:45)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.view.View.performClick(View.java:2179)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.view.View.onTouchEvent(View.java:3828)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.widget.TextView.onTouchEvent(TextView.java:6291)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.view.View.dispatchTouchEvent(View.java:3368)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
01-08 19:16:45.911: E/AndroidRuntime(774):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1707)
01-08 19:16:45.911: E/AndroidRuntime(774):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1197)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.app.Activity.dispatchTouchEvent(Activity.java:1993)
01-08 19:16:45.911: E/AndroidRuntime(774):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1691)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1525)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.os.Looper.loop(Looper.java:123)
01-08 19:16:45.911: E/AndroidRuntime(774):  at android.app.ActivityThread.main(ActivityThread.java:3948)
01-08 19:16:45.911: E/AndroidRuntime(774):  at java.lang.reflect.Method.invokeNative(Native Method)
01-08 19:16:45.911: E/AndroidRuntime(774):  at java.lang.reflect.Method.invoke(Method.java:521)
01-08 19:16:45.911: E/AndroidRuntime(774):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
01-08 19:16:45.911: E/AndroidRuntime(774):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
01-08 19:16:45.911: E/AndroidRuntime(774):  at dalvik.system.NativeStart.main(Native Method)
01-08 19:16:45.960: I/dalvikvm(774): threadid=7: reacting to signal 3
01-08 19:16:46.141: I/dalvikvm(774): Wrote stack trace to '/data/anr/traces.txt'
01-08 19:16:47.409: I/Process(774): Sending signal. PID: 774 SIG: 9

The mass_calcs class is :

public class mass_calcs extends Activity  {

    TextView masscalcs;


     /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {


        super.onCreate(savedInstanceState);
        setContentView(R.layout.mass_calcs);

        masscalcs=(TextView) findViewById(R.id.masscalcs);       
        double res=getIntent().getExtras().getDouble("value");

        masscalcs.setText("Amount of mass remaining: "+res+" mg");
    }



}
  • 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-28T02:04:32+00:00Added an answer on May 28, 2026 at 2:04 am

    Ok on the getDouble() when there is no data you will find the app crashes as there is no double provided.

    Where you have

    case R.id.mass_calcs:
            mass_func();
            break;
        }
    

    change it so that it has

    case R.id.mass_calcs:
    
            if(isNumeric(masscalcs.getText().toString()))
            {
                mass_func();
            }
            else
            {
                Toast.makeText(context, "Please provide a number", Toast.LENGTH_SHORT).show();
            }
            break;
        }
    
        public static boolean isNumeric(String str)  
        {     
          try  
          {  
            double d = Double.parseDouble(str);  
          }  
          catch(NumberFormatException nfe)  
          {  
            return false;  
          }  
          return true;  
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application, which performs some custom data gathering, transformation and reporting. Currently,
In a C# windows forms application. I have a splash screen with some multi-threaded
We have a WinForms application which runs on a touch-screen on a bit of
I have a Blackberry application which, when run in some emulators with touch support
I have an application which is some kind of MiniPaint which means I can
I would like to have the following screen in my application: button at the
I have a Silverlight application running full screen. Is there a way i can
I am creating an touch screen application using Swing and have a request to
I have an application. First I display a splash screen, a form, and this
OK, this is a slightly weird question. We have a touch-screen application (i.e., no

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.