P
P
paleniy2016-12-10 17:33:42
Android
paleniy, 2016-12-10 17:33:42

Why does mGoogleApiClient return null in onStart?

OnCreate returns [email protected]
OnStart mGoogleApiClient=null
Can anyone suggest why?

public GoogleApiClient mGoogleApiClient;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(com.BuffoApps.user.ThrowMe.R.layout.activity_main);
      GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Games.API)
                .addScope(Games.SCOPE_GAMES)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
       ...

 @Override
    protected void onStart() {
        super.onStart();
        Log.i("CONNECTION", " ONSTART mGoogleApiClient="+mGoogleApiClient);
            mGoogleApiClient.connect();    }
    }

Tried mGoogleApiClient.connect(); insert into onCreate, then the following error is in the logs:
12-10 17:16:14.961 12968-12968/com.BuffoApps.user.ThrowMe I/CONNECTION: onConnectionFailed(): attempting to resolve, Message=null, Code=4, PendingIntent {423551c8: [email protected]}
12-10 17:21:04.844 389-389/? W/ActivityManager: Unbind failed: could not find connection for [email protected]
12-10 17:21:04.852 389-676/? W/ActivityManager: Unbind failed: could not find connection for [email protected]
12-10 17:21:04.860 389-690/? W/ActivityManager: Unbind failed: could not find connection for [email protected]
12-10 17:21:05.118 14131-14131/? W/AnalyticsLogBase: PlayLogger.onLoggerFailedConnection

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rou1997, 2016-12-10
@palenyy

The error is that a onCreatelocal variable is initialized in you, and not a field of the class that is accessed onStart, the field remains null, a fairly common mistake and the specific API has nothing to do with it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question