Global Instances for Android

Jul 30, 2013 at 1:21 AM
Edited Jul 30, 2013 at 1:21 AM
How to create a global instances app for Android? Is there a guide to help? From what I understand, I need to use ConnectionFactory.GetConnectionForInstance(), but I don't see it in android SDK. Please help! Thanks!
Coordinator
Aug 7, 2013 at 4:37 PM
Hi,

The Android SDK does the dereferencing for you in ShellActivity:
private void resolveInstance(String instanceId) {
            Connection connection = ConnectionFactory.getUnauthenticatedConnection();
            connection.setAppId(HealthVaultService.getInstance().getSettings().getMasterAppId());
            HVInstance instance = new HVInstanceResolver(connection)
                    .getInstanceForId(instanceId);  
            HealthVaultSettings settings = HealthVaultService.getInstance().getSettings();
            settings.setServiceUrl(instance.getPlatformUri().toString());
            settings.setShellUrl(instance.getShellUri().toString());
            settings.setConnectionStatus(ConnectionStatus.Connected);
            settings.save();
        }
From that point on, your code can simply use HealthVaultService.getInstance().getConnection() and it will return a connection to the proper global instance.

--Rob