summaryrefslogtreecommitdiffstats
path: root/android/src/ch/asynk/rustanddust
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-02-22 15:33:59 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-02-22 15:33:59 +0100
commit76b036db2e9f632fb8315f7ff925434912671940 (patch)
treecff1d50aa8a32f9f57c0618b81ca9c0c510faee8 /android/src/ch/asynk/rustanddust
parent09ee4433efc9a62211bca3aff60415ba6d187ab0 (diff)
downloadRustAndDust-76b036db2e9f632fb8315f7ff925434912671940.zip
RustAndDust-76b036db2e9f632fb8315f7ff925434912671940.tar.gz
AndroidBackend: fetch owner's google account
Diffstat (limited to 'android/src/ch/asynk/rustanddust')
-rw-r--r--android/src/ch/asynk/rustanddust/android/AndroidBackend.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/android/src/ch/asynk/rustanddust/android/AndroidBackend.java b/android/src/ch/asynk/rustanddust/android/AndroidBackend.java
index f61a1b5..f042894 100644
--- a/android/src/ch/asynk/rustanddust/android/AndroidBackend.java
+++ b/android/src/ch/asynk/rustanddust/android/AndroidBackend.java
@@ -1,6 +1,10 @@
package ch.asynk.rustanddust.android;
import android.app.Application;
+import android.content.Context;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
import ch.asynk.rustanddust.RustAndDust;
import ch.asynk.rustanddust.util.Backend;
@@ -19,9 +23,17 @@ public class AndroidBackend implements Backend
public int getMyId() { return me; }
public int getOpponentId() { return opponent; }
+ @Override
public void init(RustAndDust game)
{
- me = game.db.storePlayerGetId("me", "myself");
+ AccountManager aMgr = (AccountManager) app.getSystemService(Context.ACCOUNT_SERVICE);
+ Account[] accounts = aMgr.getAccountsByType("com.google");
+ for (Account account : accounts)
+ RustAndDust.debug("account : " + account.toString());
+ if (accounts.length > 0)
+ me = game.db.storePlayerGetId(accounts[0].name.toString(), "myself");
+ else
+ me = game.db.storePlayerGetId("me", "myself");
opponent = game.db.storePlayerGetId("opponent", "other");
}
}