summaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/AndroidManifest.xml1
-rw-r--r--android/src/ch/asynk/rustanddust/android/AndroidBackend.java14
2 files changed, 14 insertions, 1 deletions
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
index 052ffcf..c3bf902 100644
--- a/android/AndroidManifest.xml
+++ b/android/AndroidManifest.xml
@@ -5,6 +5,7 @@
android:versionName="1.0.1" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="20" />
+ <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<application
android:allowBackup="true"
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");
}
}