Ubidots Community

Unable to customize the ubidots android app

i have followed the tutorial from ubidots on android app… i have been able to fetch the value form ubidots but i want to optimize the app according to my project… i want to get a temperature value. i have customized the code according to my understanding but it isnt working… here is my mainactivity.java

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.TextView;

import com.ubidots.ApiClient;
import com.ubidots.Value;
import com.ubidots.Variable;

public class MainActivity extends Activity {
    private static final String TEMPERATURE = "temp";
    private TextView temperature;
    protected void onCreate(Bundle savedInstanceState) {
        temperature = (TextView) findViewById(R.id.batteryLevel);


    protected void onStart() {

        new ApiUbidots().execute();
       // registerReceiver(temperature, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    protected void onStop() {
       // unregisterReceiver(mBatteryReceiver);

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

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

        protected void onPostExecute(Value[] variableValues) {



Hi, can you specify a bit why is not working? Is not getting the values from your Variable and printing it on your screen or is any other problem?

If you change this line: temperature.setText(Double.toString(variableValues[0].getValue())); to this line temperature.setText("Ubidots!"). Does it show Ubidots! or is not showing anything?


it is not showing anything at all… not even the app name… i think the issue is somewhere else…cant figure out where specifically though.
to give you the complete picture… i followed the android tutorial from ubidots having almost no prior knowledge to android programming… but then i wanted to receive values instead of sending… i did some edits and finally found the post in which asked you about concatenation… at that time it did receive the value but onstart it showed the battery level and then it changed to the value received from the cloud… so i wanted to customize the app according to my needs… i did customization by taking some help from here and there about mainactivity.java and according to what i understood… and now i am stuck here … nothing being shown on the screen now… not even the app name… hope you understand.