Note that there are some explanatory texts on larger screens.

plurals
  1. POEdittext without value force closes my App
    text
    copied!<p>I am getting a force close when there is Int on my edittext and an OK button is pressed. </p> <p>05-07 16:00:12.945: E/AndroidRuntime(28366): java.lang.NumberFormatException: unable to parse '' as integer</p> <p>Thats the logcat error I am getting. </p> <p>Here is the code: </p> <pre><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 &lt;= 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+ " &gt; 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 &gt; 255 ) { invalid.show(); } } }); </code></pre> <p>How can i tell the app if there is no value input on the <code>EditText</code> ( uin missing ) show toast, and not force close? :D</p> <p>Please be gentle on me, this is my second week with java and android, I have never had any programming language experiences before :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload