Hi everybody. ^^
I'm in the process of making an app using Game Maker Studio, and I'm trying to code an Android extension for it in Java.
Basically what I want the extension to do is start a Gallery Image picker activity, where a user can select a picture from their phone, then the selected image would be inserted into the game.
I have it so that my extension can bring up the image picker activity, but that's as far as it gets before it clonks out. ><
Upon further testing, I was able to determine that where it gets stuck is right after the startActivityForResult command. The onActivityResult method is never initiated, so the extension isn't doing anything else from there. If someone could give me an idea why this isn't working, that would be awesome. Thanks! ^^
Here is the code for my extension. Also note that the (RunnerActivity.CurrentActivity) is basically referring to the activity where the game is displayed.
I'm in the process of making an app using Game Maker Studio, and I'm trying to code an Android extension for it in Java.
Basically what I want the extension to do is start a Gallery Image picker activity, where a user can select a picture from their phone, then the selected image would be inserted into the game.
I have it so that my extension can bring up the image picker activity, but that's as far as it gets before it clonks out. ><
Upon further testing, I was able to determine that where it gets stuck is right after the startActivityForResult command. The onActivityResult method is never initiated, so the extension isn't doing anything else from there. If someone could give me an idea why this isn't working, that would be awesome. Thanks! ^^
Here is the code for my extension. Also note that the (RunnerActivity.CurrentActivity) is basically referring to the activity where the game is displayed.
Code:
package ${YYAndroidPackageName};
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import ${YYAndroidPackageName}.R;
import ${YYAndroidPackageName}.RunnerActivity;
import com.yoyogames.runner.RunnerJNILib;
public class GalleryChooser extends Activity
{
String imagePath = "";
Intent i;
private static final int RESULT_LOAD_IMAGE=1;
public void ImageSelector() {
i = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
(RunnerActivity.CurrentActivity).startActivityForResult(i, RESULT_LOAD_IMAGE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// if (requestCode == RESULT_LOAD_IMAGE && resultCode == (RunnerActivity.CurrentActivity).RESULT_OK && null != data) {
if (requestCode == RESULT_LOAD_IMAGE && null != data) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = (RunnerActivity.CurrentActivity).getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
imagePath = cursor.getString(columnIndex);
cursor.close();
}
else {imagePath = "Blank location returned :(";}
}
public String getImagePath() {
return imagePath;}
}
Last edited: