question

pravin avatar image
pravin asked pravin commented

Can we integrate android app into the clover system using API call

Hi Clover Team,

So, my question is could we integrate the android app into the clover system using API call, means can we manage the clover system by using clover API call instead of using the clover library packages? I am developing the one APP to integrate with Clover system and currently we are not able to call the service methods from clover library packages. But able to call the Clover API. Another question is which way should we preferred to integrate the android app into the clover.

Thanks, Dinesh

3 comments
10 |2000

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

Jacob Abrams avatar image Jacob Abrams ♦♦ commented ·

I don't quite understand your question. Are you building an app for Clover devices such as Clover Station or are building an app for other android devices like Samsung phones and tablets? If you are building an app for Clover devices you almost certainly should be using clover-android-sdk, I don't know why you wouldn't.

0 Likes 0 ·
pravin avatar image pravin commented ·

Yes, I am developing the android app for clover station not for any other android devices. Actually I am using the clover REST APIs to develop the app. I tried to use the clover-android -sdk, but was getting the error "android.app.ServiceConnectionLeaked: Activity order.orderdiscount.AddDiscountActivity has leaked ServiceConnection com.clover.sdk.v3.order.OrderConnector@38fcd5ec that was originally bound here". Actually I am new in android so I preferred the REST API instead of SDK. What is difference if i preferred the REST API instead of android -sdk?

0 Likes 0 ·
pravin avatar image pravin commented ·

Is it not possible to develop APP using the REST API?

0 Likes 0 ·

1 Answer

Jacob Abrams avatar image
Jacob Abrams answered pravin commented

It shouldn't be hard to fix the leak, you simply need to be sure that you call disconnect() on the OrderConnector or any other ServiceConnector when you don't need it any more. You should at least do this in your Activity#onDestroy(). Using the clover-android-sdk has numerous advantages, some of them are:

  • Your app is given auth tokens on the device automatically that can only be retrieved using the clover-android-sdk
  • Your application will function if/when the device temporarily loses network connectivity
  • Your application will be able to access information such as Items, Orders, etc MUCH faster because the clover-android-sdk retrieves data from a shared local cache
  • Your application can listen to and respond to broadcasts and events through listeners allowing it to update state and react immediately to changes made on the web, other devices and other applications in realtime
  • No need to parse JSON

It is possible to develop an app using just the REST API but it is going to be a lot more work, also it will be pretty much impossible to write a Clover Android without at least using the clover-android-sdk to obtain the correct auth tokens.

7 comments
10 |2000

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

pravin avatar image pravin commented ·

Thanks Jacob, I have tried the clover-android-sdk to integrate with clover. But I am getting the below errors,

  1. mAccount = CloverAccount.getAccount(AddDiscountActivity.this); variable 'mAccount' returning the null value. 'AddDiscountActivity' is my class/file name.

    1. InventoryConnector inventoryConnector = new InventoryConnector(AddDiscountActivity.this, mAccount, null); I have create inventoryConnector object to get items list. using "List<item> merchantItems = inventoryConnector.getItems();" but it causes an exception.
0 Likes 0 ·
pravin avatar image pravin commented ·

I have tried above functionality in android-studio as well as genymotion device(Clover station). I thought it might not work on android-studio because problem in getting the clover account details, so i tried on Genymotion device(Clover station) but on there also is not working.

0 Likes 0 ·
pravin avatar image pravin commented ·

I am getting the "Could not bind to Android service" exception for 'InventoryConnector inventoryConnector = new InventoryConnector(AddDiscountActivity.this, mAccount, null);' call

0 Likes 0 ·
pravin avatar image pravin commented ·

I am using the "modifyorderbutton" package of sample android-sdk provided on 'https://github.com/clover/android-examples/tree/master/modifyorderbutton'. and updating my code changes in it.

0 Likes 0 ·
Jacob Abrams avatar image Jacob Abrams ♦♦ commented ·

I understand you do not have an actual Clover device. Did you follow all the steps on the Clover emulator setup page: https://docs.clover.com/build/android...

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community