Android: Added basic drop file support (thanks, "noxalus"!).

This lets SDL-based apps respond to "Open With" commands properly, as they
can now obtain the requested path via a standard SDL dropfile event.

This is only checked on startup, so apps don't get drop events at any other
time, even if Android supports that, but this is still a definite
improvement.

Fixes Bugzilla #2762.
This commit is contained in:
Ryan C. Gordon 2015-05-26 20:36:45 -04:00
parent d4f288f080
commit ca08bb0d98
2 changed files with 22 additions and 0 deletions

View file

@ -173,6 +173,17 @@ public class SDLActivity extends Activity {
mLayout.addView(mSurface);
setContentView(mLayout);
// Get filename from "Open with" of another application
Intent intent = getIntent();
if (intent != null && intent.getData() != null) {
String filename = intent.getData().getPath();
if (filename != null) {
Log.v("SDL", "Get filename:" + filename);
SDLActivity.onNativeDropFile(filename);
}
}
}
// Events
@ -397,6 +408,7 @@ public class SDLActivity extends Activity {
public static native void nativeQuit();
public static native void nativePause();
public static native void nativeResume();
public static native void onNativeDropFile(String filename);
public static native void onNativeResize(int x, int y, int format, float rate);
public static native int onNativePadDown(int device_id, int keycode);
public static native int onNativePadUp(int device_id, int keycode);