bennetbrauer85 avatar image
bennetbrauer85 asked zgreathouse Deactivated answered

Receive broadcast for current orderID when employee selects order from orders app?

We need the orderID for the currently displayed order. This would be the order shown when an employee selects the order from the list in the orders app. For instance, we're able to receive a broadcast with the orderID when the register app is opened by filtering for the intent action "ACTION_ACTIVE_REGISTER_ORDER".
10 |2000

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

1 Answer

zgreathouse avatar image
zgreathouse Deactivated answered
Here is a code snippet for how to fetch the most recent (current) order:

//Async Task which fetches the current order
public class FetchOrder extends AsyncTask<Void, Void, Order> { @Override protected Order doInBackground(Void... voids) { Cursor cursor = null; String orderId = null;
//Initialize OrderConnector OrderConnector mOrderConnector = new OrderConnector(getApplicationContext(), CloverAccount.getAccount(getApplicationContext()), null); mOrderConnector.connect(); try { // Query the last order cursor = getApplicationContext().getContentResolver().query(OrderContract.Summaries.contentUriWithAccount(mAccount), new String[]{OrderContract.Summaries.ID}, null, null, OrderContract.Summaries.LAST_MODIFIED + " DESC LIMIT 1"); if (cursor != null && cursor.moveToFirst()) { orderId = cursor.getString(cursor.getColumnIndex(OrderContract.Summaries.ID)); } // return Order if most recent order is found if (orderId == "") { Log.d(TAG, "Unable to fetch order"); } else { return mOrderConnector.getOrder(orderId); } } catch (RemoteException | ClientException | ServiceException | BindingException e) { e.printStackTrace(); } finally { mOrderConnector.disconnect(); } return null; } }
10 |2000

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