summaryrefslogtreecommitdiffstats
path: root/android/src/ch
diff options
context:
space:
mode:
Diffstat (limited to 'android/src/ch')
-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");
}
}