Q:

Guess the number android app - getting crashing after enter a empty value

this is my first testing app . my app getting crashing after i didn't enter a value
this is my code

package com.study.guessnumberapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import java.util.Random;

public class MainActivity extends AppCompatActivity {
    int nu;
    public void genarate (){
        Random random = new Random();
        nu = random.nextInt(20)+1;}
    public void guess(View view) {
        EditText editText = (EditText) findViewById(R.id.editTextNumber);
        int guessvalue = Integer.parseInt(editText.getText().toString());
        String message;

        if (guessvalue > nu) {
            message = "Lower";
        } else if (guessvalue < nu) {
            message = "Higher";
        } else {
            message = "You Got it Try again";
            genarate();
        }

        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
             Log.e("Entered value", editText.getText().toString());
        Log.i("info", Integer.toString(nu));
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        genarate();
    }
} 

i know this is a basic thing i found solution for this like this 
Java Simple number game App crashes when EditText is empty
i dont know to to add that code to this one. can you help me with this 
thank you. 

A:

An empty string can not be converted into int.
Replace
int guessvalue = Integer.parseInt(editText.getText().toString());

with
int guessvalue = 0;
if(!editText.getText().toString().isEmpty()) {
    guessvalue = Integer.parseInt(editText.getText().toString());
} else {
    Toast.makeText(this, "Please enter a value.", Toast.LENGTH_SHORT).show();
    return;
}

