Load image from Android uri to NiftyImage

I can get contact’s badge using next function in Android:

[java] public Bitmap getContactBadge(int id) {

Uri uri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);

InputStream input = Contacts.openContactPhotoInputStream(getContentResolver(), uri);

if (input == null) {

return null;


return BitmapFactory.decodeStream(input);


On jME side I have form which consist information about particular contact. This form is described in xml file.

My question is: How can I load contact’s badge which I have on Android to NiftyImage on jME side?

I know the way how to set static image from asset:

[java]NiftyImage img = nifty.getRenderEngine().createImage(“Textures/dirt.jpg”, false);[/java]

http://hub.jmonkeyengine.org/groups/jmonkeyplatform/forum/topic/load-niftyimage-from-inputstream/#post-187066 almost a duplicate post