Merge pull request #3425 from Sonicadvance1/Android_add_am_launch
[Android] Add support for launching a game through activity monitor.
This commit is contained in:
commit
497a93d45f
|
@ -28,6 +28,7 @@ import org.dolphinemu.dolphinemu.model.Game;
|
||||||
import org.dolphinemu.dolphinemu.model.GameDatabase;
|
import org.dolphinemu.dolphinemu.model.GameDatabase;
|
||||||
import org.dolphinemu.dolphinemu.model.GameProvider;
|
import org.dolphinemu.dolphinemu.model.GameProvider;
|
||||||
import org.dolphinemu.dolphinemu.services.AssetCopyService;
|
import org.dolphinemu.dolphinemu.services.AssetCopyService;
|
||||||
|
import org.dolphinemu.dolphinemu.utils.StartupHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main Activity of the Lollipop style UI. Manages several PlatformGamesFragments, which
|
* The main Activity of the Lollipop style UI. Manages several PlatformGamesFragments, which
|
||||||
|
@ -90,20 +91,7 @@ public final class MainActivity extends AppCompatActivity implements LoaderManag
|
||||||
|
|
||||||
// Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
|
// Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
|
||||||
if (savedInstanceState == null)
|
if (savedInstanceState == null)
|
||||||
{
|
StartupHandler.HandleInit(this);
|
||||||
NativeLibrary.SetUserDirectory(""); // Auto-Detect
|
|
||||||
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
boolean assetsCopied = preferences.getBoolean("assetsCopied", false);
|
|
||||||
|
|
||||||
// Only perform these extensive copy operations once.
|
|
||||||
if (!assetsCopied)
|
|
||||||
{
|
|
||||||
// Copy assets into appropriate locations.
|
|
||||||
Intent copyAssets = new Intent(this, AssetCopyService.class);
|
|
||||||
startService(copyAssets);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.dolphinemu.dolphinemu.model.GameDatabase;
|
||||||
import org.dolphinemu.dolphinemu.model.GameProvider;
|
import org.dolphinemu.dolphinemu.model.GameProvider;
|
||||||
import org.dolphinemu.dolphinemu.model.TvSettingsItem;
|
import org.dolphinemu.dolphinemu.model.TvSettingsItem;
|
||||||
import org.dolphinemu.dolphinemu.services.AssetCopyService;
|
import org.dolphinemu.dolphinemu.services.AssetCopyService;
|
||||||
|
import org.dolphinemu.dolphinemu.utils.StartupHandler;
|
||||||
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
|
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
|
||||||
|
|
||||||
public final class TvMainActivity extends Activity
|
public final class TvMainActivity extends Activity
|
||||||
|
@ -118,20 +119,7 @@ public final class TvMainActivity extends Activity
|
||||||
|
|
||||||
// Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
|
// Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
|
||||||
if (savedInstanceState == null)
|
if (savedInstanceState == null)
|
||||||
{
|
StartupHandler.HandleInit(this);
|
||||||
NativeLibrary.SetUserDirectory(""); // Auto-Detect
|
|
||||||
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
boolean assetsCopied = preferences.getBoolean("assetsCopied", false);
|
|
||||||
|
|
||||||
// Only perform these extensive copy operations once.
|
|
||||||
if (!assetsCopied)
|
|
||||||
{
|
|
||||||
// Copy assets into appropriate locations.
|
|
||||||
Intent copyAssets = new Intent(this, AssetCopyService.class);
|
|
||||||
startService(copyAssets);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package org.dolphinemu.dolphinemu.utils;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||||
|
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
|
||||||
|
import org.dolphinemu.dolphinemu.services.AssetCopyService;
|
||||||
|
|
||||||
|
public final class StartupHandler
|
||||||
|
{
|
||||||
|
public static boolean HandleInit(Activity parent)
|
||||||
|
{
|
||||||
|
NativeLibrary.SetUserDirectory(""); // Auto-Detect
|
||||||
|
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
|
||||||
|
boolean assetsCopied = preferences.getBoolean("assetsCopied", false);
|
||||||
|
|
||||||
|
// Only perform these extensive copy operations once.
|
||||||
|
if (!assetsCopied)
|
||||||
|
{
|
||||||
|
// Copy assets into appropriate locations.
|
||||||
|
Intent copyAssets = new Intent(parent, AssetCopyService.class);
|
||||||
|
parent.startService(copyAssets);
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent intent = parent.getIntent();
|
||||||
|
Bundle extras = intent.getExtras();
|
||||||
|
|
||||||
|
if (extras != null)
|
||||||
|
{
|
||||||
|
String user_dir = extras.getString("UserDir");
|
||||||
|
String start_file = extras.getString("AutoStartFile");
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(user_dir))
|
||||||
|
NativeLibrary.SetUserDirectory(user_dir);
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(start_file))
|
||||||
|
{
|
||||||
|
// Start the emulation activity and send the ISO passed in.
|
||||||
|
Intent emulation_intent = new Intent(parent, EmulationActivity.class);
|
||||||
|
emulation_intent.putExtra("SelectedGame", start_file);
|
||||||
|
parent.startActivity(emulation_intent);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue