lucdowell avatar image
lucdowell asked

Cannot find inventory names

Hey guys, I've just started working with clover android SDK, and I've just finished setting up my environment. I'm now trying to run the inventory list display code found at the bottom of this page:

I had issues initially with CloverAccount.getAccount(this) which I fixed by lowering my target SDK, but now I'm having an issue with mInventoryConnector.getItems(). I am not able to get that list for some reason. I added some logs to my code:

public class MainActivity extends AppCompatActivity {

    private Account mAccount;
    private InventoryConnector mInventoryConnector;
    private TextView mTextView;

    protected void onCreate(Bundle savedInstanceState) {
        Log.d("myTag", "Creating");

    protected void onResume() {

        mTextView = (TextView) findViewById(;
        Log.d("myTag", "onResume");
        // Retrieve the Clover account
        if (mAccount == null) {
            Log.d("myTag", "Could not find account");
            mAccount = CloverAccount.getAccount(this);

            if (mAccount == null) {
                Log.d("myTag", "Couldn't find account, Exiting");

        // Connect InventoryConnector

        // Get Item
        new InventoryAsyncTask().execute();

    protected void onDestroy() {

    private void connect() {
        Log.d("myTag", "connecting");
        if (mAccount != null) {
            Log.d("myTag", "Connected");
            mInventoryConnector = new InventoryConnector(this, mAccount, null);

    private void disconnect() {
        if (mInventoryConnector != null) {
            mInventoryConnector = null;

    private class InventoryAsyncTask extends AsyncTask<Void, Void, Item> {

        protected final Item doInBackground(Void... params) {
            try {
                //Get inventory item
                Log.d("myTag", "Getting name");
                int sizeOfInventory = mInventoryConnector.getItems().size();
                Log.d("myTag", Integer.toString(sizeOfInventory));
                return mInventoryConnector.getItems().get(0);

            } catch (RemoteException | ClientException | ServiceException | BindingException e) {
            return null;

        protected final void onPostExecute(Item item) {
            if (item != null) {
                Log.d("myTag", item.getName());
            } else {
                Log.d("myTag", "Did not find item");

Here is my log output:

2020-05-23 20:02:06.465 6739-6739/? D/myTag: onResume
2020-05-23 20:02:06.465 6739-6739/? D/myTag: Could not find account
2020-05-23 20:02:06.467 6739-6739/? D/myTag: connecting
2020-05-23 20:02:06.467 6739-6739/? D/myTag: Test | (DEV)
2020-05-23 20:02:06.467 6739-6739/? D/myTag: Connected
2020-05-23 20:02:06.472 6739-6763/? D/myTag: Getting name
2020-05-23 20:02:06.640 6739-6739/? D/myTag: Did not find item

I'm logging "getting name" before the mInventoryConnector call, and trying to log the size of the list right afterwards to see if it's working, but the .getItems() function is giving me an error.

Any help is appreciated! Thank you!

clover developer communityInventory
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers


Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community