开发者

Choosing Google account for Android C2DM

开发者 https://www.devze.com 2023-02-02 18:15 出处:网络
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

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

精彩评论

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