W
Wraithious
Guest
Hello, I've run into a roadblock with trying to pass a filepath from the included files in gamemaker 1.4 to my Android extension I've made, in windows passing working_directory to a variable works as expected, such as if i put
I get the expected file path:
BUT if i run the exact same thing in android I get this result:
This is not a valid path at all, so as @FrostyCat suggested I tried using program_directory instead, but that resulted completely blank, nothing there at all, and I tried using game_save_id and that was closer, it gave me the path to the folder where the game_save saves to,
but I need the path to the included files in android, which in the gamemaker manual says working_directory is that path that I need, but it doesn't work! does anyone know what the actual path is in android? I tried many other things too like:
I'm calling my extension in 2 ways for testing:
and I rooted one of my old phones but I still can't find the file path (or the file!! and I loaded it into gms in 3 places!! the assets/Files folder in the extension folder, included files, and imported it into the resource tree)
I also tried getting it in my extension with java that works in android studio but does not work in GMS, and I made sure i injected compileFiletree(dir: 'assets/Files') in my gradle dependencies
So can anyone help me out with what the android path to the included files actually is? and why is working_directory bugged when put in a variable in android??? Are there any other workarounds anyone can suggest?
Code:
global.wrkdir=working_directory;
BUT if i run the exact same thing in android I get this result:
This is not a valid path at all, so as @FrostyCat suggested I tried using program_directory instead, but that resulted completely blank, nothing there at all, and I tried using game_save_id and that was closer, it gave me the path to the folder where the game_save saves to,
Code:
/data/user/0/com.companyname.GM_Audio_Save/files
Code:
var str=game_save_id;str=string_replace(str,"files","assets///");global.wrkdir=str;
global.wrkdir=game_save_id;
Code:
///Save audio from game to new folder
if canRec=1 SaveFromAs(global.wrkdir+"wildDubz.mp3",global.myFolder,"wildDubz.mp3",0);//get path from gms
//if canRec=1 SaveFromAs("wildDubz.mp3",global.myFolder,"wildDubz.mp3",2);//get path from java in extension
I also tried getting it in my extension with java that works in android studio but does not work in GMS, and I made sure i injected compileFiletree(dir: 'assets/Files') in my gradle dependencies
Code:
public void SaveFromAs(String inputPath, String opp, String opn, double setToRing) {
if(setToRing<2){
File f = new File(inputPath);
Log.i("yoyo", "got file: " + f.toString());
String ext = (f.getAbsolutePath().substring(f.getAbsolutePath().lastIndexOf(".")));
Log.i("yoyo", "folder is: " + opp);
boolean istrue = false;
if (f.exists()) istrue = true;
Log.i("yoyo", "File exists: " + istrue);
if(istrue){
try {
File dir = new File(opp);
if (!dir.exists()) {
dir.mkdirs();
}
InputStream in = new FileInputStream(f);
OutputStream out = new FileOutputStream(opp + "/" + opn + ext);
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
in.close();
in = null;
out.flush();
out.close();
out = null;
if(setToRing==0){
OsUpdt(opp + "/" + opn + ext);
}
if(setToRing==1){
ringFolder = (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES));
if (!ringFolder.exists()) {
ringFolder.mkdirs();
Intent rint = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
rint.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,RingtoneManager.TYPE_RINGTONE);
//rint.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");
RunnerActivity.CurrentActivity.startActivityForResult(rint, 0);
}
String rfl = ringFolder.toString() + "/";
msg = rfl + "/" + opn + ext;
MakeRingtone();
}
} catch (FileNotFoundException fnfe1) {
Log.e("tag", fnfe1.getMessage());
} catch (Exception e) {
Log.e("tag", e.getMessage());
}
}
if(!istrue){
Log.i("yoyo", "Couldn't find file");
}
}
if(setToRing==2) {
AssetManager assetManager = RunnerActivity.CurrentActivity.getAssets();Log.i("yoyo", "Game file requested: " + inputPath);
String[] files = null;
try {
files = assetManager.list("Files");Log.i("yoyo", "Looking for the file");
}
catch (Exception e) {
Log.e("Tag", e.getMessage());
}
InputStream in = null;Log.i("yoyo", "Defining Input stream");
OutputStream out = null;Log.i("yoyo", "Defining Output stream");
try
{
in = assetManager.open("Files/" + inputPath);
Log.i("yoyo", "Found the file, input stream created");
out = new FileOutputStream(opp + "/" + opn);Log.i("yoyo", "Output stream created");
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
OsUpdt(opp + "/" + opn);
}
catch(IOException e)
{
Log.i("yoyo", "Couldn't find file");
Log.e("tag", "Failed to copy asset file: " + inputPath, e);
}
}
}