Ubidots Community

[SOLVED] How i change the data from ubidots to a whole number

Hello i already use all the tutorials but when i read the data from ubidots, i have “com.ubidots.Value@88fdb4b” and i want the exactly number i dont know how to put that on whole numer the code is showed below, can you please help me?

public class MainActivity extends Activity {

    TextView textElement;

    private static final String BATTERY_LEVEL = "level";
    private TextView mBatteryLevel;
    private TextView traer;
    private BroadcastReceiver mBatteryReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            int level = intent.getIntExtra(BATTERY_LEVEL, 0);

            mBatteryLevel.setText(Integer.toString(level) + "%");
            new ApiUbidots().execute(level);

    protected void onCreate(Bundle savedInstanceState) {


        mBatteryLevel = (TextView) findViewById(R.id.batteryLevel);
        traer = (TextView) findViewById(dato);

    protected void onStart() {
        registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    protected void onStop() {

    public class ApiUbidots extends  AsyncTask<Integer, Void, Value[]> {
        private final String API_KEY = "xxxxx";
        private final String VARIABLE_ID = "xxxxx";

        protected Value[] doInBackground(Integer... params){
            ApiClient apiClient = new ApiClient(API_KEY);
            Variable batteryLevel = apiClient.getVariable(VARIABLE_ID);
            Value[] variableValues = batteryLevel.getValues();

            return variableValues;

        protected void onPostExecute(Value[] variableValues) {
            // Update your views here
            TextView textView = (TextView) findViewById(dato);




You’re printing the textual representation of that Value instance in your TextView.

To show the numeric value that the instance holds, you should change this line:


To this:

Double variableValue = variableValues[0].getValue();
1 Like

great works perfectly

Great! We’re here to help you.