Share-Extension and BitmapData

When trying to take screenshots and sharing with social networks by using Share-Extension(@fbricker ) I have these errors:

This happens when testing with neko output and it will be crashed on Android (I have not tested on iOS yet)
My Code

Share.defaultURL ="myLink";
Share.defaultSubject = "myText";

I’m using the latest version of OpenFL/Lime and Share-Extension
Any help would be appreciated!

I can confirm that sharing bitmap doesn’t work on openfl-next, works fine on legacy.
@singmajesty using lime.system.System.documentsDirectory crashes android app (fatal signal), perhaps accessing documents directory is not implemented yet?
Easy way to reproduce crash:

class Main extends Sprite 

	public function new() 
		var btn:Sprite = new Sprite();
		addChild(btn);, 1);, 0, 100, 100);
		btn.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):Void


Hello!I have these lines on my project.xml
<source path="src" />
<set name="openfl-legacy" />
<haxelib name="openfl" />
It works if you just want to share with text or links but crashed when adding BitmapData
It seems we have to wait the next update of OpenFL to fix the bugs you mentioned above because we can not access the documents directory? @singmajesty
Any ideas!

As far as I know <set name="openfl-legacy" /> won’t work with newest openfl/lime. You could try downgrading both openfl and lime. I’m using lime 2.9.0, openfl 3.6.1 and hxcpp 3.2.205 (not sure if hxcpp needs to be downgraded as well) and sharing bitmapdata works fine. Keep in mind that dowgrading libs can produce errors in other parts of your code.

1 Like

I have to update to the latest version of OpenFL/Lime because it can fix the text field bugs when scaling down. Thanks for your info! :slight_smile:

Here’s a quick fix for openfl next:
In the extension-share/2,4,2/java/ShareEx/project/android/shareex/ add

public static String getDocumentsDirectory()
    return android.os.Environment.getExternalStorageDirectory() + "/Documents/";

in extension-share\2,4,2\extension\share\Share.hx change imagePath = lime.system.System.documentsDirectory + "/" + fName; to

#if android
var documentsDirectoryMethod:Dynamic = openfl.utils.JNI.createStaticMethod("shareex/ShareEx", "getDocumentsDirectory", "()Ljava/lang/String;");
imagePath = documentsDirectoryMethod() + "/" + fName;
imagePath = lime.system.System.documentsDirectory + "/" + fName;
1 Like