question

loyalzoo avatar image
loyalzoo asked loyalzoo answered

Customer Facing Activity not started on tethered Clover Mini

Hi,

We are trying to implement customer facing activity as it is explained on this page: https://docs.clover.com/docs/using-customer-facing-platform . On page it is written that we can use CPF SDK on Clover Station Pro or a Clover Station tethered to a Clover Mini. We are using Clover Station tethered to a Clover Mini and we have some issues when we try to start our Customer Activity.

When we connect our Clover MINI to Clover Station and we run USB Pay Display application our MINI goes to IDLE state and on screen we can see Welcome message.

After everything is set up, we are trying to start custom Activity from our application installed on Clover Station but screen on Clover Mini doesn't show our CFP Activity. Screen just flush and for second there is progress dialog visible, and after that Welcome screen is shown.


Here is part of our code, so you can see how are we trying to start CFP activity, and maybe figured out what are we doing wrong:


AndroidManifest.xml

<activity android:name=".views.CustomerActivity"
    android:launchMode="singleTop"
    android:noHistory="true"
    android:windowSoftInputMode="adjustResize"
    android:fitsSystemWindows="true"
    android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
    <intent-filter>
        <action android:name="com.loyalzoo.loyalzooclover.views.CustomerActivity"/>
        <category android:name="com.clover.cfp.ACTIVITY"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>


MainActivity:

   private static final String CUSTOM_ACTIVITY_NAME = "com.loyalzoo.loyalzooclover.views.CustomerActivity";






final String payload = "{\"msg\"=\"Initial...\"}"; // if you need an inital payload
final CustomActivityRequest car = new CustomActivityRequest(CUSTOM_ACTIVITY_NAME, payload);
executor.execute(()->{
    remoteDeviceConnector.connect();
    DeviceStatusResponse deviceStatusResponse = remoteDeviceConnector.retrieveDeviceStatus(new DeviceStatusRequest());

  if(deviceStatusResponse.state.equals(ExternalDeviceState.IDLE)) {

        remoteDeviceConnector.startCustomActivity(car, new CustomActivityListener() {
            @Override
            public void onMessageFromActivity(MessageFromActivity message) {
 
            }

            @Override
            public void onCustomActivityResult(CustomActivityResponse response) {

            }
        });
    }
});


CustomerActivity:

public class CustomerActivity extends CloverCFPActivity {

    @Override protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        int orientation = this.getResources().getConfiguration().orientation;
        if (orientation == Configuration.ORIENTATION_PORTRAIT) {
            setContentView(R.layout.activity_basic_example_portrait);
            findViewById(R.id.basic_example_port_layout).setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
                    return true;
                }
            });
        }
        else{
            setContentView(R.layout.activity_basic_example);
            findViewById(R.id.basic_example_land_layout).setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
                    return true;
                }
            });
        }
    }

    @Override
    public void onMessage(String payload) {}

    @Override protected void onResume() {
        super.onResume();
        String payload = getIntent().getStringExtra(CFPConstants.EXTRA_PAYLOAD);
        ((TextView)findViewById(R.id.payload)).setText(payload);
    }

    public void finishClicked(View view) {
        String payload = ((EditText)findViewById(R.id.resultPayload)).getText().toString();
        setResultAndFinish(RESULT_OK, payload);
    }
}


It is also quite unusual that CloverCFPActivity class is marked as deprecated, and we are using cfp-sdk 4.2.1

implementation "com.clover.cfp:clover-cfp-sdk:4.2.1

Is that supposed to be like that or we are pulling something wrong?

Looking forward to your answer.
Best regard

Clover Android SDKClover Mini
1 comment
10 |2000

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

Blake Williams avatar image Blake Williams ♦ commented ·

CloverCFPActivity is deprecated because we will not be updating it going forward. The path forward is to use CloverCFPActivityHelper, which provides the functionality in CloverCFPActivity, but doesn't require extending a specific base class.


Do you have a logcat that indicates any issues trying to start the activity? Seeing the progress dialog sounds like it calls start on the Mini, but there is a problem initializing your custom activity.

0 Likes 0 ·

1 Answer

·
loyalzoo avatar image
loyalzoo answered

Hi,

Thank you for your replay this helped us to solve our issue.

Now we have another problem when we start a payment screen inside of Register application. Usually when we start payment screen, tethered Mini changes display to the payment display. When we start our Custom Activity, it seems that we have priority over payment screen that is launched from Register app, and instead of payment display on tethered Mini our Custom Activity is displayed.
Is there a way we can set priorities for our custom activity so that the payment screen is automatically displayed on the MINI device, or we need to manually remove our activity so the payment screen can appear on tethered MINI?
Currently we are using intent ACTIVE_REGISTER_ORDER, and when order id is null we are removing our activity from tethered MINI, but problem with this implementation is that we receive that same intent when we exit Register app and we are removing our activity, but we would like to have it on screen when we are outside of the Register app.


If there is no way to automatically remove our activity when payment is started, is there any intent when payment is initiated so we can remove our activity?

Best regards

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