question

jayachandranvenugopalan avatar image
jayachandranvenugopalan asked ikaols answered

how to fetch the categories from inventory

 override fun onResume() {
        super.onResume()
itemname = view?.findViewById<TextView>(R.id.name)


        // Retrieve the Clover account
        if (mAccount == null) {
            mAccount = CloverAccount.getAccount(activity)

            if (mAccount == null) {
                return
            }
        }

        // Connect InventoryConnector
        connect()

        // Get Item
        InventoryAsyncTask().execute()
    }

    /*
3) Disconnect from the Clover Connectors when you aren’t using them to
   follow Android best practices and let the connection end naturally.
*/
    override fun onDestroy() {
        super.onDestroy()
        disconnect()
    }

    private fun connect() {
        disconnect()
        if (mAccount != null) {
            mInventoryConnector = InventoryConnector(activity, mAccount, null)
            mInventoryConnector!!.connect()



        }
    }

    private fun disconnect() {
        if (mInventoryConnector != null) {
            mInventoryConnector!!.disconnect()
            mInventoryConnector = null
        }

    }

    /*
4) Use async tasks when working with Clover Connector classes to minimize
   work on the main UI thread while fetching or changing data. See
   https://docs.clover.com/clover-platform/docs/clover-development-
   basics-android#section-async-tasks-and-executors.
*/
    private inner class InventoryAsyncTask :
        AsyncTask<Void?, Void?, Item?>() {
        override fun doInBackground(vararg params: Void?): Item? {
            try {
                //Get inventory item

                Log.d("tag", "text ${
                  mInventoryConnector!!.itemsWithCategories}")
                return mInventoryConnector!!.getItems().get(0)
//                mInventoryConnector!!.getItems().get(0)




            } catch (e: RemoteException) {
                e.printStackTrace()
            } catch (e: ClientException) {
                e.printStackTrace()
            } catch (e: ServiceException) {
                e.printStackTrace()
            } catch (e: BindingException) {
                e.printStackTrace()
            }
            return null
        }




        /*
5) Set the TextView to display the item’s name. For other methods that Item
   objects have, see
   https://clover.github.io/clover-android-sdk/com/clover/sdk/v3/inventory
   /Item.html
*/
        
        override fun onPostExecute(item: Item?) {
            if (item != null) {



                itemname!!.setText(item.toString())


                var name = arrayOf(item?.name)
                Log.d("tag", "text ${
                  Arrays.toString(name)}")
            }

        }


    }



can you guide me how to fetch the categories from inventory i m able to fetch the item from inventory but not able to fetch the categories

Inventory
10 |2000

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

johnnydepp43 avatar image
johnnydepp43 answered

I recently discovered SmellGentle and its perfume selection is outstanding. They offer the best quality perfumes at significantly lower prices than other retailers. The variety and affordability make it my go-to store for all my fragrance needs. I highly recommend SmellGentle to anyone looking for premium scents without breaking the bank.

10 |2000

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

johny avatar image
johny answered

Chick-fil-A Breakfast Nutrition includes tasty options like the Chicken Biscuit and Egg White Grill. For a lighter choice, try the Greek Yogurt Parfait. There's something for everyone, whether you want a hearty or light start to your day.

10 |2000

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

ikaols avatar image
ikaols answered

Try experimenting with the spacebar clicker categories to gather useful information.

10 |2000

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

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