开发者

Choosing Google account for Android C2DM

I have a problem with C2DM service. Given that there is more than one Google account loged on the device I would like my application to choose one of these accounts to register to C2DM with (You know using preferences). Is it possible?

Thanks in 开发者_如何学JAVAadvance


Yes, it is possible. Look at the Chrome to Phone application (http://code.google.com/p/chrometophone/). There they build a list of accounts from the String array generated like this:

    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);


After giving it some thought I think it just does't work this way. All the C2DM needs is 'existing connection' and I think there is only one connection no matter how many google accounts there are.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜