question

John R. Roberts avatar image
John R. Roberts asked

Must I catch exception to test for Amazon Maps?

This is more under the Feedback category. :) I followed the Amazon Maps website samples and had the following method in my code: private boolean checkForAmazonMaps() { // Check for the presence of Amazon Maps on the device return AmazonMapsRuntimeUtil .isAmazonMapsRuntimeAvailable(this) == ConnectionResult.SUCCESS; } However on a Google Nexus 6 device I got a class not found exception with this code. To get my code to run on that device I changed it to: private boolean checkForAmazonMaps() { boolean b = false; // Check for the presence of Amazon Maps on the device try { b = AmazonMapsRuntimeUtil .isAmazonMapsRuntimeAvailable(this) == ConnectionResult.SUCCESS; } catch (java.lang.NoClassDefFoundError je) { Log.e(TAG, "Amazon maps not found!"); b = false; } return b; } This code catches the exception and "works" on the Google Nexus 6. Is this the expected behavior? Namely that you have to catch this exception in case your app is running on a non-Amazon device? I had to catch that exception or my app crashed. thanks, John R.
amazon maps
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Nick Gardner avatar image
Nick Gardner answered
This is one I haven't seen before. There doesn't seem to be any harm in catching the exception, but it is interesting that it is only on that device. Have you been able to test this on more devices, and if so, are there any others that exhibited this behavior? Thanks, Nick
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.