• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Android Extension not creating Social Async

Y

Yukikofriend

Guest
Hello all! First time poster, long time lurker. I would normally refrain from bugging you all with a problem which likely has a very simple solution, but this has left me baffled.

This is the Java extension code:

package ${YYAndroidPackageName};

import ${YYAndroidPackageName}.R;
import com.yoyogames.runner.RunnerJNILib;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;


public class ImageConverterDSMap {

final static int EVENT_OTHER_SOCIAL = 70;

//turns file into a byte string
public void image_to_byte_string(String filepath) {
File f = new File(filepath);
String result = "";
FileInputStream fis = null;
byte[] b = new byte[(int) f.length()];
try {
fis = new FileInputStream(f);
fis.read(b);
for (byte i : b) {
result += i + ",";
}
}
catch (IOException ioe) {
ioe.printStackTrace();
result = "Failed.";
}
finally {
try { fis.close(); } catch (IOException|NullPointerException e) {e.printStackTrace();}
}
int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
RunnerJNILib.DsMapAddString( dsMapIndex,"type", "finished" );
RunnerJNILib.DsMapAddString( dsMapIndex, "result", result );
RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
}

//turns byte string into a file
public void image_from_byte_string(String str, String fname) {
String result = "null";
File f = new File(fname);
FileOutputStream fos = null;
String[] toParse = str.split(",");
byte[] b = new byte[toParse.length];
for (int i = 0; i<toParse.length; i++) {
b = Byte.parseByte(toParse);
}
try {
fos = new FileOutputStream(f);
fos.write(b);
result = fname;
}
catch (IOException ioe) {
ioe.printStackTrace();
result = "Failed.";
}
finally {
try { fos.close(); } catch (IOException ioe) {ioe.printStackTrace();}
}
int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
RunnerJNILib.DsMapAddString( dsMapIndex,"type", "finished" );
RunnerJNILib.DsMapAddString( dsMapIndex, "result", result);
RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
}
}


This is the GML code that runs the functions:

Mouse Left Pressed event:

var src = "cutekiko.png";

if (file_exists(src)) {
image_to_byte_string(src);
instance_deactivate_object(oExecuteImageOutput);
}
else {
text = "Incorrect path.";
}

And this is in the Social async event itself:

var type = async_load[? "type"];
if (type == "finished") {
text = async_load[? "result"];
instance_activate_object(oExecuteImageOutput);
}

I've run the code and - according to the "text" variable being drawn on the screen as a debug method - it appears as though the Social event won't trigger at all. To make sure that it wasn't just the methods themselves, I ran the ReturnAsync method from the Gamemaker Studio Android Native Extension tutorial and even something as simple as that isn't triggering the async event. Does anyone have any ideas as to where I may have gone wrong?

Thanks in advance for reading!
 
Top