2

Problem:

There is a noticeable delay - of around 40-50+ seconds, from the time the application is launched on the wearable to the point the DatalayerService is started.

Evidence:

09-15 10:19:09.594 455-475/? I/ActivityManager﹕ Displayed com.test.watches/.WatchfaceActivity: +860ms

09-15 10:20:05.104 1775-1775/? V/Watchface﹕ Starting up Google api client

09-15 10:20:05.234 1775-1775/? V/Watchface﹕ Called connect on google api client in onCreate()


Clearly from the timestamps there is a delay of around 55 seconds, from the time the user starts up the application on the wearable to the point the data transfer starts.

This is unacceptable since the user will simply assume that the code is buggy.

My code looks like the typical workflow. After the connection establishes - things run smoothly, however, on bootup or on a fresh install of the app, connecting to the data layer takes for ever!!

My code:

public class DataLayerListenerService extends WearableListenerService {

    private static final String TAG = "Watchface";

    GoogleApiClient mGoogleApiClient;

    @Override
    public void onCreate() {
        super.onCreate();
        Log.v("Watchface", "Starting up Google api client");

        mGoogleApiClient = new GoogleApiClient.Builder(getApplicationContext())
                            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                                @Override
                                public void onConnected(Bundle connectionHint) {
                                    Log.i(TAG, "onConnected: " + connectionHint);
                                }

                                @Override
                                public void onConnectionSuspended(int cause) {
                                    Log.i(TAG, "onConnectionSuspended: " + cause);
                                }
                            })
                            .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
                                @Override
                                public void onConnectionFailed(ConnectionResult result) {
                                    Log.i(TAG, "onConnectionFailed: " + result);
                                }
                            })
                            .addApi(Wearable.API)
                            .build();
        mGoogleApiClient.connect();
        Log.v("Watchface", "Called connect on google api client in onCreate()");

    }

At this point I am contemplating manually booting up the DataLayerListenerService in onCreate() of my main activity. I dont think that is recommended practice - but I'm not sure if I have much option.

rmoh21
  • 1,405
  • 6
  • 19
  • 36
  • Can you post the onCreate to to api connection code? From the log it just looks like something in your code has caused delay on the main thread – RyPope Sep 15 '14 at 17:33
  • Posted code. Looks pretty standard - btw I have also added a comment to see if you can manually startup DataLayerListenerService if you wanted to. – rmoh21 Sep 15 '14 at 17:43
  • Try adding a log between build() and connect(), just to make sure the issue is on the network and not the builder – RyPope Sep 15 '14 at 17:58
  • Well based on the log above, that cant be the case. 09-15 10:20:05.104 1775-1775/? V/Watchface﹕ Starting up Google api client 09-15 10:20:05.234 1775-1775/? V/Watchface﹕ Called connect on google api client in onCreate() There is all but a few split seconds difference. – rmoh21 Sep 15 '14 at 18:05

0 Answers0