question

Ramya avatar image
Ramya asked ·

Not able to listen events from OrderV3Connector.OnOrderUpdateListener2

Whenever lineItem added,deleted and updated in Register app, we want to trigger an event
Seen this post https://community.clover.com/questions/14833/is-t... tried code in clover mini sandbox but unable to receive events

We are using below code
Created OrderV3Connector.OnOrderUpdateListener2 as Service
public class LineItemService extends Service implements OrderV3Connector.OnOrderUpdateListener2 {
// order added, delete and other related methods
}

Started service
Intent intent= new Intent(getApplicationContext(), LineItemService.class);
startService(intent);

//Manifest
<service android:name=".activities.LineItemService"/>

clover android sdk gradle
implementation 'com.clover.sdk:clover-android-sdk:221.9'

Please suggest
OrdersSandboxClover Android SDKLineItemsBroadcasts
10 |2000 characters needed characters left characters exceeded

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

1 Answer

· Write an Answer
Jeffrey Blattman avatar image
Jeffrey Blattman answered ·
That's not quite how it works. You'd create a foreground service that adds itself (or some other class that implements OnOrderUpdateListener2) using OrderConnector.addOnOrderChangedListenener().

Note that there's really no reliable way to stay listening forever. If you make your service foreground Android will prefer to keep it in memory, but there are no guarantees.

Alternatively you can register for ACTION_LINE_ITEM_ADDED in your manifest. See class Intents in SDK for documentation. This isn't really great either as it means the OS has to start your app every time a line item is added to an order. In fact if you target later versions of Android they simply do not allow you to listen for such things from a manifest registered receiver.
3 comments Share
10 |2000 characters needed characters left characters exceeded

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

Thanks Jeffrey.

But is there any other option available to listen all events (Item added, updated and deleted)?

0 Likes 0 · ·

There is not.

0 Likes 0 · ·
Ramya avatar image Ramya Jeffrey Blattman ♦♦ ·

Ok, Thanks Jeffrey.

0 Likes 0 · ·

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