Upfront disclaimer: I've been working on my latest project pretty hard for the past few weeks, so I'm getting very tired...
I have a sub that takes a String argument & returns a bitmap. I perform a test on the string to see if it's Null & if it isn't loads the file in the string, else it loads a default image:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
I call this function from a couple of different places in my Main activity. In one call I use the result from a query & in the other I just pass Null, or a String set to Null.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
So here's the problem. In the first call (where "icon" is the result of the query) if the query returns Null, it works fine - BUT - if I pass Null, the If statement evaluates to true & the app crashes.
According to the documentation, the return type from ExecQueryResult2 is either a String, or Null. The variable ("icon") receiving the return value from the query is a String. Even if I declare a String, assign Null to it & then pass it to the sub, it still crashes. If I change the sub argument type to Object, it works fine.
Why does it work when a String that has been set to Null by ExecQuerySingleResult2 is passed, but not when a String that has been set to Null (or just Null) is passed?
- Colin.
			
			I have a sub that takes a String argument & returns a bitmap. I perform a test on the string to see if it's Null & if it isn't loads the file in the string, else it loads a default image:
			
				B4X:
			
		
		
		'In my AppUtils module
Public Sub getMarkerIcon(icon As String) As Bitmap
    Private iconImg As Bitmap
   
    If icon <> Null Then 
        iconImg.Initialize(File.DirAssets, icon) 
    Else 
        iconImg.Initialize(File.DirAssets, "icon_default.png")
    End If
   
    Return CreateScaledBitmap(iconImg, 25dip, 25dip)
End SubI call this function from a couple of different places in my Main activity. In one call I use the result from a query & in the other I just pass Null, or a String set to Null.
			
				B4X:
			
		
		
		    Private icon As String = Starter.sqlDB.ExecQuerySingleResult2("SELECT GroupIcon FROM tblGroups WHERE GroupName=?", Array As String(group))
    Private m1 As Marker = gmap.AddMarker3(lat, lon, title, AppUtils.getMarkerIcon(icon))
'AND
    Private m1 As Marker = gmap.AddMarker3(lat, lon, title, AppUtils.getMarkerIcon(Null))
'OR
    Private icon as String = Null
    Private m1 As Marker = gmap.AddMarker3(lat, lon, title, AppUtils.getMarkerIcon(icon))So here's the problem. In the first call (where "icon" is the result of the query) if the query returns Null, it works fine - BUT - if I pass Null, the If statement evaluates to true & the app crashes.
According to the documentation, the return type from ExecQueryResult2 is either a String, or Null. The variable ("icon") receiving the return value from the query is a String. Even if I declare a String, assign Null to it & then pass it to the sub, it still crashes. If I change the sub argument type to Object, it works fine.
Why does it work when a String that has been set to Null by ExecQuerySingleResult2 is passed, but not when a String that has been set to Null (or just Null) is passed?
- Colin.
 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		