我对 C2DM 服务有疑问。鉴于在设备上登录了多个 Google 帐户,我希望我的应用程序选择其中一个帐户注册到 C2DM(您知道使用首选项)。是否可以?
提前致谢
我对 C2DM 服务有疑问。鉴于在设备上登录了多个 Google 帐户,我希望我的应用程序选择其中一个帐户注册到 C2DM(您知道使用首选项)。是否可以?
提前致谢
是的,有可能。查看 Chrome to Phone 应用程序 ( http://code.google.com/p/chrometophone/ )。在那里,他们从生成的字符串数组中构建了一个帐户列表,如下所示:
ArrayList<String> accountNames = new ArrayList<String>();
Account[] accounts = AccountManager.get(this).getAccounts();
for (Account account : accounts) {
if (account.type.equals("com.google")) {
accountNames.add(account.name);
}
}
String[] result = new String[accountNames.size()];
accountNames.toArray(result);
在给它一些想法之后,我认为它只是不以这种方式工作。C2DM 的所有需求都是“现有连接”,我认为无论有多少谷歌帐户,都只有一个连接。