Skip to content Skip to sidebar Skip to footer

Android Discount App Is Not Running

I am making a simple discount app for android, but my app is not running and hope you guys can help me to figure whats wrong with it. I am new to android development, so maybe I am

Solution 1:

This is most likely your problem

listedPrice = Double.parseDouble(userInput.getText().toString());

The user hasn't had a chance to enter something with this code in onCreate() so unless you have something hard-coded, you will get a NumberFormatException. You need to place that code in an onClick() or some other event after the user has had a chance to enter something.

You should also do some error-checking such as putting it inside of a try/catch.

try
{
    listedPrice = Double.parseDouble(userInput.getText().toString());
}
catch (NumberFormatException e)
{
    // do something if invalid double
}

When posting here, you need to clearly state what is/isn't working as expected and what your problem is. Also, if your app crashes then there will be output in the logcat and you need to post that so we can easily see what/where the problem is.

Eclipse didn't say you have any problem because this is a runtime error which means that Eclipse didn't see anything wrong at compile time. Meaning your syntax is correct, as far as Eclipse knows, but your logic is not.

Post a Comment for "Android Discount App Is Not Running"