Thanks to expert advice from
@JordiCP, this is mostly solved. He took the thought of making NB6 work with a resource rather than a file and made it into reality - and as it turned out, that got rid of the crashes.
It seems that some versions of Android crashes in a really awful way when one tries to use a bitmap as icon. This means that this is the sub from NB6 that causes the problem:
Public Sub SmallIcon (Icon As Bitmap) As NB6
If IsBuilder Then
NotificationBuilder.RunMethod("setSmallIcon", Array(CreateIconFromBitmap(Icon)))
End If
Return Me
End Sub
This is what
@JordiCP came up with instead. First of all, make sure that the icon is 72x72 and in gray-scale with transparency. This is important, otherwise the icon will just be a filled box. Place the file in Objects\Res\Drawable (read-only)
Then use this code instead of SmallIcon above.
Public Sub SmallIcon (Icon as Bitmap) As NB6
If IsBuilder Then
Dim jo2 As JavaObject
jo2=Me
Dim id As Int = jo2.RunMethod("retrieveResourceId",Null)
NotificationBuilder.RunMethod("setSmallIcon", Array(id))
End If
Return Me
End Sub
#if JAVA
public int retrieveResourceIdStatus() {
return R.drawable.the_icon_file;
}
#End If
This is not at all as polished as it should be. For instance, the Icon as Bitmap part is not used as the icon is referenced in the Java code. But it was enough to stop the crashes and display the correct icon.
Some quick notes:
- 72x72 seems to be fine regardless of display scale
- Some devices (Jordi can comment on this) failed to get the correct icon and instead showed the app icon - but at least neither the app nor the phone did crash
Again, let me point out that this is not at all as polished as it should be, there's room for improvements.
(I'm hoping that Erel might be able to comment and adjust it to make it rock solid.
)