Ubidots Community

[SOLVED] How control relay arduino with android?

Hi, i am rizal.
i got problem about controll relay from android. i want every time user click button relay on .
i have ubidots account, if i press widget button from things.ubidots.com relay connected perfectly. but my problem if i control via android.i search in this forum and i try every code but nothing. please help.
i use android studio. for get value from ubidots to android , i already done.
my code for send data to ubidots :

    protected void onCreate(Bundle savedInstanceState) {
        ImageButton siram_pupuk = findViewById(R.id.buttonpemupukan);
        mPupukLevel = (TextView) findViewById(R.id.jarak_pupuk);
        status_pupuk = (TextView) findViewById(R.id.textView4);
        siram_pupuk.setOnClickListener(new View.OnClickListener()
            public void onClick(View v)
                Toast.makeText(getApplicationContext(), "ON", Toast.LENGTH_SHORT).show();
                SendApiUbidots sendApi = new SendApiUbidots();
        new ApiUbidots().execute(5);
        //return null;

 public class SendApiUbidots extends AsyncTask<Integer, Void, Void>{
        private final String API_KEY = "YOUR API-KEY";
        private final String VARIABLE_ID_2 = "YOUR VARIABLE";

        protected Void doInBackground(Integer... params) {
            ApiClient apiClient = new ApiClient(API_KEY);
            Variable switchVariable = apiClient.getVariable(VARIABLE_ID_2);

            return null;


Greetings @fahrizal06008 ,

The Ubidots JAVA library is outdated and we are working in its update (it was tested for android 5.0 and below). If you are getting errors I advise you to create your own request that fits our REST API to retrieve your variable’s value using apiClient or another HTTP requests library for Java.

All the best
Maria C.