Issue
Hey all I am trying to use an Intent to start an app called RetroArch and pass the needed paramiters to it in order for it to start the game without the need to use the RetroArch GUI.
I have a few references I've been looking at: This This This This and This
The code I have come up with is this:
public void onAddPicClick(String name) {
String gameName = name.replace(".png", "").replace(" ", "_");
Uri romPath = Uri.parse("android.resource://com.cpt.sample/raw/" + gameName);
/*Uri rom = Uri.parse(
"am start " +
"--user 0 " +
"-n com.retroarch/.browser.retroactivity.RetroActivityFuture " +
"-e ROM android.resource://com.example.telluridetainment/raw/" + gameName + ".nes " +
"-e LIBRETRO /data/data/com.retroarch/cores/fceumm_libretro_android.so " +
"-e CONFIGFILE /storage/emulated/0/Android/data/com.retroarch/files/retroarch.cfg " +
"-e QUITFOCUS " +
"--activity-clear-top " +
"--activity-clear-task " +
"--activity-no-history"
);*/
//Bundle b = new Bundle();
Intent intent = new Intent(Intent.ACTION_MAIN,null);
//Intent intent = getActivity().getPackageManager().getLaunchIntentForPackage("com.retroarch");
//intent.setData(rom);
//intent.putExtra("n", "com.retroarch/.browser.retroactivity.RetroActivityFuture");
intent.putExtra("ROM", romPath);
intent.putExtra("LIBRETRO", "/data/data/com.retroarch/cores/nestopia_libretro_android.so");
intent.putExtra("CONFIGFILE", "/storage/emulated/0/Android/data/com.retroarch/files/retroarch.cfg");
//b.putString("QUITFOCUS", null);
//b.putString("activity-clear-top", null);
//b.putString("activity-clear-task", null);
//b.putString("activity-no-history", null);
//intent.putExtras(b);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
startActivity(intent);
}
I have been able to start RetroArch but have yet been able to run the ROM without user interaction.
So, what is the correct way to code this for an Intent?
Solution
After hours and hours of trial and error I finally got it working. I'm posting the final code here just in case someone else stumbles upon this issue and needs a solution.
Below is for the NES games Core and I'm using the 64bit RetrtoArch Plus apk
try {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.retroarch.aarch64", "com.retroarch.browser.retroactivity.RetroActivityFuture"));
intent.setAction("com.retroarch.aarch64/.browser.retroactivity.RetroActivityFuture");
intent.putExtra("ROM", "/storage/emulated/0/games/nes/Mario.nes");
intent.putExtra("LIBRETRO", "/data/data/com.retroarch.aarch64/cores/nestopia_libretro_android.so");
intent.putExtra("CONFIGFILE", "/storage/emulated/0/Android/data/com.retroarch.aarch64/files/retroarch.cfg");
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
startActivity(intent);
} catch (Exception e) {
Log.d("RetroArchDebugError", e.getMessage());
}
Notes:
- If using the 32-bit RetroArch version then substitute com.retroarch.aarch64 to com.retroarch.
- The /storage/emulated/0/... is the internal storage path.
- The Cores (.../cores/...) need to be replaced depending on what emulator you wish to use.
You can get the emulators name from here
Answered By - StealthRT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.