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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:45:27+00:00 2026-06-03T16:45:27+00:00

I am getting a force close when there is Int on my edittext and

  • 0

I am getting a force close when there is Int on my edittext and an OK button is pressed.

05-07 16:00:12.945: E/AndroidRuntime(28366): java.lang.NumberFormatException: unable to parse ” as integer

Thats the logcat error I am getting.

Here is the code:

//Button OK

Button bOK = (Button) findViewById(R.id.bOK);
bOK.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {
        // TODO Auto-generated method stub

        Toast invalid = Toast.makeText(getApplicationContext(), "Only values between 0-255 will be accepted.", Toast.LENGTH_LONG);
        uin = Integer.parseInt(value.getText().toString());

        if ( uin <= 255 ) {
            Process process = null;
            try {
                process = Runtime.getRuntime().exec("su");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            DataOutputStream os = new DataOutputStream(process.getOutputStream());
            try {
                os.writeBytes("chmod 644 sys/class/leds/button-backlight/brightness\n");
                os.writeBytes("echo " +uin+ " > sys/class/leds/button-backlight/brightness\n");
                os.writeBytes("chmod 444 sys/class/leds/button-backlight/brightness\n");
                os.writeBytes("exit\n");
                os.flush();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } else if ( uin > 255 ) {
            invalid.show(); 
        }
    }
});

How can i tell the app if there is no value input on the EditText ( uin missing ) show toast, and not force close? 😀

Please be gentle on me, this is my second week with java and android, I have never had any programming language experiences before 🙂

  • 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-03T16:45:29+00:00Added an answer on June 3, 2026 at 4:45 pm

    You need to surround the line uin = Integer.parseInt(value.getText().toString());
    with a try/catch block like this

    try {
        uin = Integer.parseInt(value.getText().toString());
    } catch(NumberFormatException e){
        //do something here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my app is getting force close randomly. And every time error can not be
Hi I am facing a problem in Message dialog, getting Force close my code
In My application( PhotoCrop) i am getting force close after 4 or 5 images
I have done this and it is not working. I am getting force close
How do you force a web browser to use POST when getting a url?
Im trying to display this listview, but I keep getting a: 07-17 21:14:22.233: ERROR/AndroidRuntime(349):
To make a long story short, I'm having trouble getting a couple of Java
Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo
Getting started with TDD and I want to ground up a Repository-driven Model. However,
Getting the above error in following code. How to rectify it. Thanks. Please look

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.