The reason you cannot βadd casts to android via eclipseβ is because you are not the one who defines interfaces or superclasses. If you want to add an exception to the method signature (as you say, you do it fine), it must also be added to the interface, and you do not control them, so you cannot change it.
For example, the method
protected void onCreate (Bundle savedInstanceState);
which you override in action, if you want to throw an exception, the method signature should be changed to (for example)
protected void onCreate (Bundle savedInstanceState) throws a MyException;
but then it will also need to change where the onCreate function is defined, which is in the Activity class, and this is a class that you cannot change (because it is provided by the android library).
Therefore, your only option is to catch the Exception and do something with it (or just ignore it). You can make a toast to display an error
catch (Exception e) { Toast toast = Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT); toast.show(); }
monkjack
source share