Retrieving geopoints from User Custom Property

Buenas
I add a GeoPoint Relation Property to User Table,
I set this property using the following code:

GeoPoint geoPoint = new GeoPoint(CURRENT_GEO_LOCATION.getLatitude(), CURRENT_GEO_LOCATION.getLongitude());
currentUser.setProperty("location", geoPoint);

But when a retrive it

GeoPoint geoPoint = (GeoPoint) currentUser.getProperty("location");

Throw this exception

Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to com.backendless.geo.GeoPoint

How can i retrieve this property. I am Android API.Thanks in AdvanceBrocy Centeio

Hello, Brocy!
We cannot reproduce this issue. Make sure that you’re using the latest android SDK.

Also, clarify please how do you retrieve the user from database? Provide the part of code which produces this problem.
best regards,
Alex

In attach image of the user property configuration.

private void UpdateUserLocation() {

    BackendlessUser currentUser = Backendless.UserService.CurrentUser();

    if (null == currentUser || CURRENT_GEO_LOCATION == null) return;

    // EXCEPTION OCCUR IN THIS LINE <<<<<<<<<<<<<<--------------------------
    GeoPoint geoPoint = (GeoPoint) currentUser.getProperty("location");

    if (null == geoPoint)
        geoPoint = new GeoPoint(CURRENT_GEO_LOCATION.getLatitude(), CURRENT_GEO_LOCATION.getLongitude());
    else {
        geoPoint.setLatitude(CURRENT_GEO_LOCATION.getLatitude());
        geoPoint.setLongitude(CURRENT_GEO_LOCATION.getLongitude());
    }

    String type = currentUser.getProperty("type").toString();

    if (null == type || type.isEmpty()) return;

    geoPoint.addCategory(type);
    //geoPoint.addMetadata("user", currentUser);

    if (type.equals(getString(R.string.user_type_seller_text))) {
        geoPoint.addMetadata("Product", new ArrayList&lt;String&gt;());
    }

    currentUser.setProperty("location", geoPoint);

    Backendless.UserService.update(currentUser, new AsyncCallback&lt;BackendlessUser&gt;() {
        public void handleResponse(BackendlessUser user) {
            Log.e(TAG, String.format("Update user location SUCESS = %s", user.getProperty("location")));
        }

        public void handleFault(BackendlessFault fault) {
            Log.e(TAG, String.format("Update user location FAULT = %s", fault));
        }
    });
}

And i am using this version of sdk for Android

compile 'com.backendless:backendless:3.0.15.1'

I dont know if this is releate but when I use the Code generator the User Class dont have the location property


package com.backendless.oli.login;


import com.backendless.BackendlessUser;


public class OLiUser extends BackendlessUser
{
  public String getEmail()
  {
    return super.getEmail();
  }


  public void setEmail( String email )
  {
    super.setEmail( email );
  }


  public String getPassword()
  {
    return super.getPassword();
  }


  public String getGender()
  {
    return (String) super.getProperty( "gender" );
  }


  public void setGender( String gender )
  {
    super.setProperty( "gender", gender );
  }


  public String getImei()
  {
    return (String) super.getProperty( "imei" );
  }


  public void setImei( String imei )
  {
    super.setProperty( "imei", imei );
  }


  public String getName()
  {
    return (String) super.getProperty( "name" );
  }


  public void setName( String name )
  {
    super.setProperty( "name", name );
  }


  public String getPicture()
  {
    return (String) super.getProperty( "picture" );
  }


  public void setPicture( String picture )
  {
    super.setProperty( "picture", picture );
  }


  public String getType()
  {
    return (String) super.getProperty( "type" );
  }


  public void setType( String type )
  {
    super.setProperty( "type", type );
  }
}

Thank you for the code, now I’m able to reproduce it. I’ve opened an internal task for it. Task id is BKNDLSS-12540.
For now I can offer you the following workaround ( I assume that autoload is set for “location” ):

Backendless.UserService.findById( Backendless.UserService.CurrentUser().getObjectId(), new AsyncCallback&lt;BackendlessUser&gt;() { ..... );

Also notify please that extending BackendlessUser class is not a good idea, avoid it please.
best regards,
Alex

The workaround works like charm, thanks for the quick support your are the best.