Background Thread for Android App

Hi,

I’ve been working on an Android App that goes with a Photon. I’ve new to app development and haven’t had much experience. I’m trying to subscribe to events that the photon publishes to the cloud and a webhook that the photon triggers. However, I don’t understand how to make a new thread to work with the photon.

Any advice or resources would be appreciated.

Thanks,
Cass

I’m not a Java expert here but when you hook up an event listener it will be just sitting there till an event arrives and do its job asynchronously by default without you needing to donate an extra thread for it.

https://docs.particle.io/reference/android/#subscribe-to-events

Ok. That’s good to know. My biggest problem is when I try to log in to the cloud I get the following error:

method logIn must be called from worker thread, currently inferred thread is main

@cass By default all network calls in Android has to be in separate thread. You can make use of our Async class as specified here https://docs.particle.io/reference/android/#sdk-calls-from-the-ui-thread