question

ramya avatar image
ramya asked raman22500 answered

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
OrdersClover Android SDKSandboxLineItemsBroadcasts
10 |2000

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

Jeffrey Blattman avatar image
Jeffrey Blattman answered ramya commented
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
10 |2000

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

ramya avatar image ramya commented ·

Thanks Jeffrey.

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

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ ramya commented ·

There is not.

0 Likes 0 ·
ramya avatar image ramya Jeffrey Blattman ♦♦ commented ·

Ok, Thanks Jeffrey.

0 Likes 0 ·
raman22500 avatar image
raman22500 answered

@Ramya can you please share your code here so that we can check how did you solve your problem?

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