Refactor this thing into oblivion soon


Hello we are using the Particle Device setup android library to have our photon connected to the particle cloud. We had to manually create some of the Login and Register pages, which ended up having us recreate the DiscoverDeviceActivity file.

The problem is, when claiming I need to set the DeviceSetupState.deviceNeedsToBeClaimed to true; which I can’t do that outside the class.

Then I saw the following todo:
// FIXME: Statically defined, global, mutable state… refactor this thing into oblivion soon.

Do you know when this will be fixed? Our project is stalled due to this

Thank you for the time.


Let me ping someone that might be able to help, @rickkas7 are you able to assist?



Thank you @KyleG


Are there any updates?


From current setup library code it appears that DeviceSetupState.deviceNeedsToBeClaimed is always true. Did you ever notice value become false, or is it an assumption that state must be set to true manually?


@julius thanks for the response. It is an assumption. We weren’t going anywhere with that.

Basically we redesigned the login and register page in order to handle additional fields (in the Register page). We couldn’t just customize the UI because we needed a way to send the custom fields to our server, so we recreated the Register and Login page.

We reverted to the provided classes in Setup Library (DiscoverDevice and GettingStarted). However, in DiscoverDeviceActivity page there is a Logout button which takes us to the OLD Login page rather than our own. Do you know of a way to Remove the logout button from DiscoverDeviceActivity OR link the Logout button to take us to our new Login page?

Any other suggestions are appreciated.


@julius I just went back to the code and refreshed my memory. It is the following code that we are unable to set due to the package modifier.

// In -- line 131-134
DeviceSetupState.claimCode = result.claimCode;
if (truthy(result.deviceIds)) {


I’ll have to go through code to check if we allow logout to be overridden. But first I need a bit more info, which version of setup-library you are working with?

As for claim code change, it is a different issue, claim code is set from Api response /v1/device_claims or /v1/products/{productId}/device_claims.
Not sure why one would change claim code, however, we will check if we can change access to a variable for an upcoming version.


If we can just hide the Logout button (from the Choose Device page) then it would solve our problem.


@julius We are working with 0.4.9


In Android you should be able to override resources by creating a resource with the same name in your project, for example, the layout used in Discover Device Activity (where you choose device & logout) is “activity_discover_device.xml”.

However layout file is manipulated from code, logout button is being set to “visible” depending on “setupOnly” flag (perhaps setupOnly fits your needs). Simple workaround for that is to wrap logout button in another viewgroup and hide it:

    //replace current logout view with this


Keep in mind that customizing flow this way is not recommended, if possible any other customizations should be done as shown here.


@julius that worked perfectly. Thanks!