I want to check BitmapDescriptor for null.
The documentation for BitmapDescriptorFactory.fromAsset states that:
Returns the BitmapDescriptor that was loaded from the asset or null if failed to load.
BitmapDescriptor bd = BitmapDescriptorFactory.fromAsset("markerimages/filename.png");
if (bd == null) {
// doSomething...
}
Despite this, I am unable to catch BitMapDescriptor in a null state - even when I pass a filename that does not exist, the fromAsset method does not return a null.
It may be that the fromAsset method doesn't return null, but perhaps returns the same as defaultMarker() returns. (i.e. the documentation is wrong)
I'd check whether the value you get for a (presumably non-existent) asset is either '==' or .Equals the defaultMarker(). That could be how you detect a non-existent asset.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With