I'm getting error on my fragment class which is state that
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.common.api.GoogleApiClient.isConnected()' on a null object reference at fragment.HomeFragment.onResume
This is my partial code on HomeFragment
private GoogleApiClient mGoogleApiClient;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        mCurrentLocation = savedInstanceState.getParcelable(KEY_LOCATION);
        mCameraPosition = 
savedInstanceState.getParcelable(KEY_CAMERA_POSITION);
    }        buildGoogleApiClient();
}
@Override
public void onResume() {
    super.onResume();
    if (mGoogleApiClient.isConnected()) {
        getDeviceLocation();
    }
    updateMarkers();
}
    private synchronized void buildGoogleApiClient() {
    GoogleApiClient.Builder builder = new GoogleApiClient.Builder(getActivity());
    mGoogleApiClient = builder.build();
    //builder.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */);
    builder.addConnectionCallbacks(this);
    builder.addApi(LocationServices.API);
    builder.addApi(Places.GEO_DATA_API);
    builder.addApi(Places.PLACE_DETECTION_API);
    builder.build();
    createLocationRequest();
}
I also implemented
- OnMapReadyCallback
- GoogleApiClient.ConnectionCallbacks
- GoogleApiClient.OnConnectionFailedListener
- LocationListener
- DirectionFinderListener
Can someone help me with this?
 
    