# apply

Call the **apply** API to activate the card application activity.

## Method signature

```kotlin
fun apply(activity: Activity, requestCode: Int, apduServiceName: String)
```

## Request parameters

| **Item** | **Type** | **Description** | **Required** |
| --- | --- | --- | --- |
| activity | Activity | The context of the current activation page. | Required |
| requestCode | int | The code that will be returned to `onActivityResult()` to identify this card application request. | Required |
| apduServiceName | String | The customized **APDU** service name during integration. | Required |

## Response parameters

N/A

## Sample

```java
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;

public class YourActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.your_layout); // Replace with your layout file name

        // Find the button by its ID and set an OnClickListener
        Button btnApplyCard = findViewById(R.id.btn_apply_card);
        btnApplyCard.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                applyCard();
            }
        });
    }

    // Method to initiate the card application process
    private void applyCard() {
        // Start the activation process
        ApplyCardActivity.apply(this, 0x01, "com.iap.android.tappayment.verify.hce.IAPNFCHostApduService");
    }

    // Handle the result of the activity
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == 0x01) {
            switch (resultCode) {
                case ApplyCardActivity.APPLY_RESULT_SUCCESS:
                    // Activation successful
                    break;
                case ApplyCardActivity.APPLY_RESULT_FAILURE:
                    // Activation failed
                    break;
                case ApplyCardActivity.APPLY_RESULT_PROCESSING:
                    // Activation in progress
                    break;
                case ApplyCardActivity.APPLY_RESULT_CANCELED:
                    // Activation canceled
                    break;
            }
        }
    }
}
```