Issues in using Android SDK of photon

We want to access data from sensors connected to photon on our Android Application using Android SDK. For that purpose we want to proceed as follow:
1.To get login to Particle cloud
2.Display list of devices on next screen
3.From this list user can choose any of device then display all variables corresponding to a account
4.From here user select desired variable and then ultimately data of that variable is displayed on Android Application.
So far we have only code for login to particle account and reading data from a variable.But we are getting error That VARIABLE DOES NOT EXIST.Code is as follow:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ParticleCloudSDK.init(this);
        setContentView(R.layout.activity_main);

        findViewById(R.id.login_button).setOnClickListener(
                v -> {
                    final String email = ((EditText) findViewById(R.id.email)).getText().toString();
                    final String password = ((EditText) findViewById(R.id.password)).getText().toString();

                    // Don't:
                    @SuppressLint("StaticFieldLeak")
                    AsyncTask task = new AsyncTask() {
                        @Override
                        protected Object doInBackground(Object[] params) {
                            try {
                                ParticleCloudSDK.getCloud().logIn(email, password);
                                Toaster.l(MainActivity.this, "Logged in");

                            } catch (final ParticleCloudException e) {
                                Runnable mainThread = () -> {
                                    Toaster.l(MainActivity.this, e.getBestMessage());
                                    e.printStackTrace();
                                    Log.d("info", e.getBestMessage());
//                                            Log.d("info", e.getCause().toString());
                                };
                                runOnUiThread(mainThread);

                            }

                            return null;
                        }

                    };
//                        task.execute();

                    //-------

                    // DO!:
                    Async.executeAsync(ParticleCloudSDK.getCloud(), new Async.ApiWork<ParticleCloud, Object>() {

                        private ParticleDevice mDevice;

                        @Override
                        public Object callApi(@NonNull ParticleCloud sparkCloud) throws ParticleCloudException, IOException {
                            sparkCloud.logIn(email, password);
                            sparkCloud.getDevices();
                            mDevice = sparkCloud.getDevice("3b0020000851363136363935");
                            Object obj;


                            try {
                                String strVariable = mDevice.getStringVariable("temp");
                                Log.d("BANANA", "Temperature: " + strVariable);
                            } catch (ParticleDevice.VariableDoesNotExistException e) {
                                Toaster.s(MainActivity.this, "Error reading variable");
                            }




                            return -1;

                        }

                        @Override
                        public void onSuccess(@NonNull Object value) {
                            Toaster.l(MainActivity.this, "Logged in");
                         Intent intent = ValueActivity.buildIntent(MainActivity.this, 123, mDevice.getID());
                           startActivity(intent);
                        }

                        @Override
                        public void onFailure(@NonNull ParticleCloudException e) {
                            Toaster.l(MainActivity.this, e.getBestMessage());
                            e.printStackTrace();
                            Log.d("info", e.getBestMessage());
                        }
                    });
                }
        );
    }
}

We have following queries:
1.What is Tag in Log.d
2. Is it possible to access variable without calling that function in which variable exists.
Kindly answer these questions as soon as possible.
Thank you.

It's not clear what you mean by this. The variable needs to be global, so there is no function that you need to call.

1 Like

image
Can you explain what is Tag here and what we should write instead of “BANANA” inour code?

Double posted here
How to login on Android ... Keep It Simple

You can write anything you want instead of BANANA. The tag is used to identify the source of the message, so you can tell where in your program that particular log came from. Since that log is inside the callAPI function, I would suggest either “callAPI” or “strVariable”, it’s up to you.