-1

I am using the Android-Sharing-Extension-ANE.

How to share an image as result from my application code?

This code does not work

var bitmap:Bitmap = ...;

// encoding image by native encoder (availible on FP 11.3/AIR 3.3 or newer)
var bitmapBytes:ByteArray = bitmap.bitmapData.encode(new Rectangle(0, 0, bitmap.width, bitmap.height), new JPEGEncoderOptions(70)));

var file:File = File.documentsDirectory.resolvePath("image_for_share.jpg");

var stream:FileStream = new FileStream(); // write file to local memory
stream.open(file, FileMode.WRITE);
stream.writeBytes(fileBytes);
stream.close();

SharingExtension.shareImage(file, "Choser title", "Message"));
VC.One
  • 14,790
  • 4
  • 25
  • 57

1 Answers1

0

"How do I share an image with this ANE I use Animate CC?"

From the "Read Me" of that ANE:

How to use:

  • Connect com.illuzor.extensions.SharingExtension.ane file to your Android AIR project.
  • Import com.illuzor.sharingextension.SharingExtension;

Since it's not clear what your exact problem is (because not enough information given)...

(1) Did you import the required Class files?

import com.illuzor.sharingextension.SharingExtension; 


btn_Share.addEventListener (MouseEvent.CLICK, shareAndroid); 


function shareAndroid (event: MouseEvent): void 
{
    //# If this works then replace with bitmap code (use shareImage)
    SharingExtension.shareText ("AS3 Test", "This text is from AS3 code"); 

}

(2) Did you add (connect) the ANE to your project (in Settings)?

Read this for advise on adding an ANE:
https://www.adobe.com/devnet/air/articles/using-ane-in-flash.html

VC.One
  • 14,790
  • 4
  • 25
  • 57
  • Share text code works SharingExtension.shareText ("AS3 Test", "This text is from AS3 code"); Share image code does not work SharingExtension.shareImage(file, "Choser title", "Message"); – Ayman Abdel Nasser Mar 04 '19 at 08:47
  • If you're serious about getting some help, you have to **give your helpers some useful info**. You tell me _"code does not work"_ so maybe stop using it if you downloaded a broken library code.... But I think it's not broken. Just you are not telling us what happens when you try to compile an APK. Does it compile successfully? Is your `File` pointing to a working image file? Can you successfully open same image file (`image_for_share.jpg` on device) with other programs? – VC.One Mar 08 '19 at 02:25