I poked around the extension a bit and figured it out. There's a problem with devices that only have phone storage. It's not necesarily about having an sd card since some phones have the storage split in 2 even if they have no sd card, and the extension works on those phones also. I fixed it by only writing the screenshot to internal storage, so now it works on all phones.
My fix isn't ideal since it uses a deprecated mode for "openFileOutput", but it should do the trick until someone can fix it the proper way.
You have to replace the contents of the Share.java file, somewhere inside the extension's folder, with this
/**
*
* Stencyl Extension, Create by Robin Schaafsma
* wwww.byrobingames.com
*
**/
package com.byrobin.simpleshare;
import org.haxe.lime.*;
import android.content.Intent;
import android.app.Activity;
import android.content.res.AssetManager;
import android.content.Context;
import android.content.ContentValues;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayInputStream;
import android.net.Uri;
import android.graphics.Bitmap;
import android.util.Base64;
import android.provider.MediaStore;
import android.util.Log;
import org.haxe.extension.Extension;
public class Share extends Extension
{
public static String path;
public static Uri uri;
private static boolean shareSucceed = false;
private static boolean shareFailed = false;
public static void shareContent(final String msg, final String url, final boolean withImage)
{
mainActivity.runOnUiThread(new Runnable()
{
public void run()
{
if(!withImage)
{
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, msg + "\n\n" + url);
Extension.mainContext.startActivity(Intent.createChooser(intent, "Share via..."));
shareSucceed = true;
shareFailed = false;
}
}
});
}
public static void saveImageAndShare (final String msg, final String url, final String base64Img)
{
mainActivity.runOnUiThread(new Runnable()
{
public void run()
{
Bitmap image = convertToImage(base64Img);
/* String path = MediaStore.Images.Media.insertImage(Extension.mainContext.getContentResolver(), convertToImage(base64Img), "Screenshot" , "Drawing");*/
//Comment: path - Extension.mainContext.getCacheDir() &
try {
// Use the compress method on the Bitmap object to write image //to
// the OutputStream
FileOutputStream fos = Extension.mainContext.openFileOutput("screen.png", Context.MODE_WORLD_READABLE);
// Writing the bitmap to the output stream
image.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
} catch (Exception e) {
Log.e("saveToInternalStorage()", e.getMessage());
}
File filePath = Extension.mainContext.getFileStreamPath("screen.png");
Log.e("file path ", filePath.toString());
Uri fileUri = Uri.fromFile(filePath);
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_TEXT, msg + "\n\n" + url);
intent.putExtra(Intent.EXTRA_STREAM, fileUri);
Extension.mainContext.startActivity(Intent.createChooser(intent, "Share via.."));
shareSucceed = true;
shareFailed = false;
}
});
}
public static Bitmap convertToImage(String image)
{
try
{
InputStream stream = new ByteArrayInputStream(Base64.decode(image.getBytes(), Base64.DEFAULT));
Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(stream);
return bitmap;
}
catch (Exception e)
{
return null;
}
}
static public boolean shareResultSucceed()
{
if(shareSucceed)
{
shareSucceed = false;
return true;
}
return false;
}
static public boolean shareResultFailed()
{
return shareFailed;
}
}
Hope it helps!