[Help]Fix these return?

Dear all,

I have code from android studio `

PrinterTextParserImg.bitmapToHexadecimalString(printer, this.getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM);

`

I want implements to App Inventor Extension function,How to fix?
Implements for "R.drawable.logo"?

I have try :

@SimpleFunction
public String DrawableToHexadecimalString(String logo){
return PrinterTextParserImg.bitmapToHexadecimalString(printer, container.$context().getResources().getDrawableForDensity(logo, DisplayMetrics.DENSITY_MEDIUM));
}

Thanks before,

Regard,
kangris

One way to do this is to upload “logo” as an asset, then:

Get the Bitmap from the asset:

Then convert the Bitmap to a Drawable:

4 Likes

If the icon is stored in the extension, you can use Form’s openAssetForExtension in combination with MediaUtil’s getBitmapDrawable to obtain a BitmapDrawable. Extensions do not support using Android-style resource files at this time.

3 Likes

Thanks sir @Ken
This helpfull :pray: :grinning:

1 Like