Logging into the Particle Cloud in Android app (2)

So here is a link to a question that displays the exact problem I am having:

The issue was never resolved and no one posts on it anymore so I started my new topic. I am having trouble with this right here:

    try {
        // Init the CloudSDK
        ParticleCloudSDK.init(ChooseLeagueActivity.this);
        ParticleCloudSDK.getCloud().logIn("<my email here>", "<password here>");
        Toaster.s(ChooseLeagueActivity.this, "Logged in!");
        // Now we're logged in, we want to read a list of devices

    } catch (ParticleCloudException e) {
        e.printStackTrace();
        Toaster.s(ChooseLeagueActivity.this, "FAILED TO LOGIN!");
    }

it never logs me in and I always get the popup: "failed to login"
Here is the error I get:
W/System.err: io.particle.android.sdk.cloud.ParticleCloudException
W/System.err: at io.particle.android.sdk.cloud.ParticleCloud.logIn(ParticleCloud.java:173)

Let me know if anyone knows why this is happening. Thanks

I am beginning to think it is something with compiling the cloudsdk remotely:
compile ‘io.particle:cloudsdk:0.4.8’

I am going to try to install the cloudsdk onto my computer

Where are you calling that code from? You can’t make that call from the UI thread, basically anything in response to a button or the main UI setup won’t work. You can only make that call from an async task or background thread:

https://docs.particle.io/reference/android/#sdk-calls-from-the-ui-thread

2 Likes

Thank you!!! this was the solution to my problem.

1 Like