Is there a safe way to handle an exception thrown by super.onCreate(savedInstanceState)
?
A very small number of my users are hitting this error
java.lang.NoClassDefFoundError - android.security.MessageDigest
The causes are discussed in this question, but basically onCreate
for the MapActivity class can throw a NoClassDefFoundError
. I'm concerned that detecting the condition in advance may not be future proof.
I thought the safest solution for my class (which extends MapActivity) would be to catch the NoClassDefFoundError
and launch a URL to Google maps instead, e.g.
try {
super.onCreate(savedInstanceState);
} catch (NoClassDefFoundError err) {
StringBuilder url = new StringBuilder(
"http://maps.google.com/maps?q=").append(latitude)
.append(",").append(longitude).append("&z=18");
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url.toString()));
startActivity(i);
finish();
return;
}
However, I'm worried that my code will crash with a SuperNotCalledException
when the NoClassDefFoundError
occurs.
Is there a safe way to handle exceptions/errors in a call to super.onCreate?