Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check BitmapDescriptor for null

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.

like image 455
burntsugar Avatar asked Feb 06 '14 03:02

burntsugar


1 Answers

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.

like image 174
John Visosky Avatar answered Sep 21 '22 20:09

John Visosky