A example of what? However, you can’t actually return a Bitmap
.
getting a error at this in = openAssetForExtension(image);
error - cannot find symbol
here is my imports
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;
I’ve updated my post half an hour ago to fix this error
does i need to import form class
Yes you have.
@SimpleFunction
public void SetupView(AndroidViewComponent layout, String image) throws Exception {
try{
in = container.$form().openAssetForExtension(this, image);
} catch (IOException e) {
} finally {
in.close();
}
it gives me an error
Attempt to invoke in.close();
on a null object reference
hope you solve this error soon @Mohamed_Tamer
If you want to open a file from assets, you can try this:
InputStream inputStream = container.$form().openAsset(image);
i have already tell you that you can pass the inputStream
to @SimpleEvent
Is it like this :
@SimpleFunction
public void pick(String imagePath) {
InputStream inputStream = container.$form().openAsset(imagePath);
AfterPicking(inputStream);
}
@SimpleEvent
public void AfterPicking(String imagePath) {
EventDispatcher.dispatchEvent(this, "AfterPicking", imagePath);
}
yes, your code should work fine
okay i wil try
You can’t pass an inputStream
to a SimpleEvent
so what should i do?
why do you need to pass inputStream
I don’t know, but my goal is I want to get image From Asset and put it in the imageview app inventor, but put it using @SimpleEvent
you need to convert inputStream to Bitmap and then set image view’s image
but how do I get the image using @SimpleEvent
Like this: