API Reference
Complete reference for NetFUNNEL Android Agent functions, callbacks, and response formats.
Table of Contents
- Initialization Functions
- Basic Control Functions
- Section Control Functions
- Callback Classes
- Response Object Schema
- Status Codes Reference
- Best Practices
- Utility Functions
Initialization Functions
Netfunnel.initialize
Purpose: Initialize the NetFUNNEL Android Agent with required configuration.
Function Signature:
- Kotlin
- Java
Netfunnel.initialize(
clientId: String,
networkTimeout: Long = 3000,
retryCount: Int = 0,
printLog: Boolean = false,
errorBypass: Boolean = false,
useNetfunnelTemplate: Boolean = true,
userId: String? = null,
useNetworkRecoveryMode: Boolean = false,
statusBarStyle: String? = null
)
Netfunnel.INSTANCE.initialize(
String clientId,
long networkTimeout,
int retryCount,
boolean printLog,
boolean errorBypass,
boolean useNetfunnelTemplate,
String userId,
boolean useNetworkRecoveryMode,
String statusBarStyle
)
Quick Parameter Overview:
| Category | Parameters | Purpose |
|---|---|---|
| Required | clientId | Essential client configuration |
| Network | networkTimeout, retryCount, useNetworkRecoveryMode | Network behavior and reliability |
| Debugging | printLog | Enable debug logging |
| Error Handling | errorBypass | Control error behavior |
| UI/Template | useNetfunnelTemplate, statusBarStyle | Waiting room appearance |
| Advanced | userId | User identification for whitelist/blacklist |
Basic Example:
- Kotlin
- Java
Netfunnel.initialize(
clientId = "{{CLIENT_ID}}"
)
Netfunnel.INSTANCE.initialize(
"{{CLIENT_ID}}"
);
Complete Example with All Options:
- Kotlin
- Java
Netfunnel.initialize(
clientId = "{{CLIENT_ID}}",
networkTimeout = 5000,
retryCount = 2,
printLog = true,
errorBypass = false,
useNetfunnelTemplate = true,
userId = "user_12345",
useNetworkRecoveryMode = true,
statusBarStyle = "auto"
)
Netfunnel.INSTANCE.initialize(
"{{CLIENT_ID}}",
5000, // networkTimeout
2, // retryCount
true, // printLog
false, // errorBypass
true, // useNetfunnelTemplate
"user_12345", // userId
true, // useNetworkRecoveryMode
"auto" // statusBarStyle
);
For detailed information about all initialization parameters, their ranges, behavior, and usage examples, see the Configuration Options Reference.
Basic Control Functions
Basic Control limits the entry speed to your service. When the start function is called, a key is issued and the waiting room appears. When the stop function is called, the key is returned.
nfStart
Purpose: Issue a key and display the waiting room for basic control.
Function Signature:
- Kotlin
- Java
Netfunnel.nfStart(
projectKey: String,
segmentKey: String,
callback: NetfunnelCallback,
activity: Activity
)
Netfunnel.INSTANCE.nfStart(
String projectKey,
String segmentKey,
NetfunnelCallback callback,
Activity activity
)
Parameters:
| Parameter | Type | Description | Required |
|---|---|---|---|
projectKey | String | Basic Control project key from console | Yes |
segmentKey | String | Basic Control segment key from console | Yes |
callback | NetfunnelCallback | Callback to handle VWR events | Yes |
activity | Activity | Current activity context | Yes |
Returns: void
Example:
- Kotlin
- Java
Netfunnel.nfStart(
projectKey = "service_1",
segmentKey = "segKey_8612",
callback = myCallback,
activity = this
)
Netfunnel.INSTANCE.nfStart(
"service_1",
"segKey_8612",
myCallback,
this
);
nfStop
Purpose: Return the key after entry is completed.
Function Signature:
- Kotlin
- Java
Netfunnel.nfStop(
projectKey: String,
segmentKey: String,
completeCallback: NetfunnelCompleteCallback? = null
)
Netfunnel.INSTANCE.nfStop(
String projectKey,
String segmentKey,
NetfunnelCompleteCallback completeCallback
)
Parameters:
| Parameter | Type | Description | Required |
|---|---|---|---|
projectKey | String | Basic Control project key from console | Yes |
segmentKey | String | Basic Control segment key from console | Yes |
completeCallback | NetfunnelCompleteCallback? | Callback for key return confirmation | No |
Returns: void
Example:
- Kotlin
- Java
Netfunnel.nfStop(
projectKey = "service_1",
segmentKey = "segKey_8612",
completeCallback = myCompleteCallback
)
Netfunnel.INSTANCE.nfStop(
"service_1",
"segKey_8612",
myCompleteCallback
);
If you do not execute the stop function, the key will be returned automatically according to the segment timeout setting (default timeout: 20 seconds).
Section Control Functions
Section Control maintains a fixed number of concurrent users in a specific section. When the start function is called, a key is issued; until the stop function is called, the user is considered to be in the active section, and the next user in the queue is not admitted.
Use Cases:
- Multi-step processes: After entering an event page, purchasing products, and clicking the payment completion button
- User session management: From user login until logout
- Resource-intensive operations: Maintaining optimal user count for specific features
nfStartSection
Purpose: Issue a key and display the waiting room for section control.
Function Signature:
- Kotlin
- Java
Netfunnel.nfStartSection(
projectKey: String,
segmentKey: String,
callback: NetfunnelCallback,
activity: Activity
)
Netfunnel.INSTANCE.nfStartSection(
String projectKey,
String segmentKey,
NetfunnelCallback callback,
Activity activity
)
Parameters:
| Parameter | Type | Description | Required |
|---|---|---|---|
projectKey | String | Section Control project key from console | Yes |
segmentKey | String | Section Control segment key from console | Yes |
callback | NetfunnelCallback | Callback to handle VWR events | Yes |
activity | Activity | Current activity context | Yes |
Returns: void
Example:
- Kotlin
- Java
Netfunnel.nfStartSection(
projectKey = "service_1",
segmentKey = "section_segKey_1234",
callback = myCallback,
activity = this
)
Netfunnel.INSTANCE.nfStartSection(
"service_1",
"section_segKey_1234",
myCallback,
this
);
nfStopSection
Purpose: Return the key when the user exits the active section.
Function Signature:
- Kotlin
- Java
Netfunnel.nfStopSection(
projectKey: String,
segmentKey: String,
completeCallback: NetfunnelCompleteCallback? = null
)
Netfunnel.INSTANCE.nfStopSection(
String projectKey,
String segmentKey,
NetfunnelCompleteCallback completeCallback
)
Parameters:
| Parameter | Type | Description | Required |
|---|---|---|---|
projectKey | String | Section Control project key from console | Yes |
segmentKey | String | Section Control segment key from console | Yes |
completeCallback | NetfunnelCompleteCallback? | Callback for key return confirmation | No |
Returns: void
Example:
- Kotlin
- Java
Netfunnel.nfStopSection(
projectKey = "service_1",
segmentKey = "section_segKey_1234",
completeCallback = myCompleteCallback
)
Netfunnel.INSTANCE.nfStopSection(
"service_1",
"section_segKey_1234",
myCompleteCallback
);
If you do not execute the stop function, the user is considered to remain in the active section, which may delay the next user's admission.
Callback Classes
NetfunnelCallback
Purpose: Handle responses from NetFUNNEL server for start functions.
In Android, NetfunnelCallback is an interface that requires implementing ALL methods. You cannot implement only some methods - you must provide implementations for all callback methods. However, some methods are more critical than others. For basic implementations, you can use TODO("Not yet implemented") for optional methods, but you should replace these with proper implementations in production code.
Abstract Methods:
| Method | Required | Description | Implementation Strategy |
|---|---|---|---|
onSuccess | Yes | Called when entry is granted or bypassed | Always implement - Core business logic |
onError | Yes | Called when a system error occurs | Always implement - Usually proceed with business logic |
onNetworkError | Yes | Called when network connection issues occur | Always implement - Retry or proceed with business logic |
onBlock | Optional | Called when user is blocked | Can use TODO initially - Show blocked message |
onClose | Optional | Called when user closes waiting room | Can use TODO initially - Handle user cancellation |
onContinue | Optional | Called for custom waiting room updates | Can use TODO initially - Only needed for custom waiting rooms |
Basic Implementation (Step-by-Step):
For initial development, you can implement only the essential methods and use TODO for others:
- Kotlin
- Java
import com.nf4.NetfunnelCallback
class StartCallback {
companion object {
private const val TAG = "NetFUNNEL"
}
private val callback = object : NetfunnelCallback() {
override fun onSuccess(statusCode: Int, message: String) {
Log.d(TAG, "onSuccess $statusCode $message")
// Core business logic - ALWAYS implement
proceedWithAction()
}
override fun onError(statusCode: Int, message: String) {
Log.d(TAG, "onError $statusCode $message")
// Usually proceed with business logic - ALWAYS implement
proceedWithAction()
}
override fun onNetworkError(statusCode: Int, message: String) {
Log.d(TAG, "onNetworkError $statusCode $message")
// Retry or proceed with business logic - ALWAYS implement
proceedWithAction()
}
override fun onBlock(statusCode: Int, message: String) {
TODO("Not yet implemented")
}
override fun onClose(statusCode: Int, message: String) {
TODO("Not yet implemented")
}
override fun onContinue(statusCode: Int, message: String, aheadWait: Int, behindWait: Int, waitTime: String, progressRate: Int) {
TODO("Not yet implemented")
}
}
fun getCallback(): NetfunnelCallback = callback
}
import com.nf4.NetfunnelCallback;
public class StartCallback {
private static final String TAG = "NetFUNNEL";
private final NetfunnelCallback callback = new NetfunnelCallback() {
@Override
public void onSuccess(int statusCode, @NonNull String message) {
Log.d(TAG, "onSuccess " + statusCode + " " + message);
// Core business logic - ALWAYS implement
proceedWithAction();
}
@Override
public void onError(int statusCode, @NonNull String message) {
Log.d(TAG, "onError " + statusCode + " " + message);
// Usually proceed with business logic - ALWAYS implement
proceedWithAction();
}
@Override
public void onNetworkError(int statusCode, @NonNull String message) {
Log.d(TAG, "onNetworkError " + statusCode + " " + message);
// Retry or proceed with business logic - ALWAYS implement
proceedWithAction();
}
@Override
public void onBlock(int statusCode, @NonNull String message) {
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void onClose(int statusCode, @NonNull String message) {
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void onContinue(int statusCode, @NonNull String message, int aheadWait, int behindWait, @NonNull String waitTime, int progressRate) {
throw new UnsupportedOperationException("Not yet implemented");
}
};
public NetfunnelCallback getCallback() {
return callback;
}
}
Complete Implementation (Production Ready):
For production code, implement all methods with proper handling:
- Kotlin
- Java
import com.nf4.NetfunnelCallback
class StartCallback {
companion object {
private const val TAG = "NetFUNNEL"
}
private val callback = object : NetfunnelCallback() {
override fun onSuccess(statusCode: Int, message: String) {
Log.d(TAG, "onSuccess $statusCode $message")
/**
* Queue passage processing logic
* ex - Service screen entry processing
*/
proceedWithAction()
}
override fun onError(statusCode: Int, message: String) {
Log.d(TAG, "onError $statusCode $message")
/**
* System error handling logic - proceed with business logic to maintain service availability
* ex - Server errors are typically temporary and shouldn't block user access
*/
proceedWithAction()
}
override fun onNetworkError(statusCode: Int, message: String) {
Log.d(TAG, "onNetworkError $statusCode $message")
/**
* Network error handling logic - log only, don't execute business logic
* ex - Use useNetworkRecoveryMode = true for automatic network recovery
*/
// Note: Business logic not executed here - relies on network recovery mode
}
override fun onBlock(statusCode: Int, message: String) {
Log.d(TAG, "onBlock $statusCode $message")
/**
* User entry blocking processing logic
* ex - Show access restriction message
*/
showBlockedMessage()
}
override fun onClose(statusCode: Int, message: String) {
Log.d(TAG, "onClose $statusCode $message")
/**
* User cancellation processing logic (WebView closes and returns to previous screen automatically)
* ex - Show exit notification Toast
*/
handleUserCancel()
}
override fun onContinue(statusCode: Int, message: String, aheadWait: Int, behindWait: Int, waitTime: String, progressRate: Int) {
Log.d(TAG, "onContinue $statusCode $message")
/**
* Waiting progress UI update logic (only applicable when using custom waiting room)
* ex - Update real-time waiting information to custom waiting screen
*/
updateCustomWaitingRoom(aheadWait, behindWait, waitTime, progressRate)
}
}
fun getCallback(): NetfunnelCallback = callback
}
import com.nf4.NetfunnelCallback;
public class StartCallback {
private static final String TAG = "NetFUNNEL";
private final NetfunnelCallback callback = new NetfunnelCallback() {
@Override
public void onSuccess(int statusCode, @NonNull String message) {
Log.d(TAG, "onSuccess " + statusCode + " " + message);
/**
* Queue passage processing logic
* ex - Service screen entry processing
*/
proceedWithAction();
}
@Override
public void onError(int statusCode, @NonNull String message) {
Log.d(TAG, "onError " + statusCode + " " + message);
/**
* System error handling logic - proceed with business logic to maintain service availability
* ex - Server errors are typically temporary and shouldn't block user access
*/
proceedWithAction();
}
@Override
public void onNetworkError(int statusCode, @NonNull String message) {
Log.d(TAG, "onNetworkError " + statusCode + " " + message);
/**
* Network error handling logic - log only, don't execute business logic
* ex - Use useNetworkRecoveryMode = true for automatic network recovery
*/
// Note: Business logic not executed here - relies on network recovery mode
}
@Override
public void onBlock(int statusCode, @NonNull String message) {
Log.d(TAG, "onBlock " + statusCode + " " + message);
/**
* User entry blocking processing logic
* ex - Show access restriction message
*/
showBlockedMessage();
}
@Override
public void onClose(int statusCode, @NonNull String message) {
Log.d(TAG, "onClose " + statusCode + " " + message);
/**
* User cancellation processing logic (WebView closes and returns to previous screen automatically)
* ex - Show exit notification Toast
*/
handleUserCancel();
}
@Override
public void onContinue(int statusCode, @NonNull String message, int aheadWait, int behindWait, @NonNull String waitTime, int progressRate) {
Log.d(TAG, "onContinue " + statusCode + " " + message);
/**
* Waiting progress UI update logic (only applicable when using custom waiting room)
* ex - Update real-time waiting information to custom waiting screen
*/
updateCustomWaitingRoom(aheadWait, behindWait, waitTime, progressRate);
}
};
public NetfunnelCallback getCallback() {
return callback;
}
}
Response Handling Strategy:
| Response Type | Status Code | Action | Business Logic | User Notification |
|---|---|---|---|---|
| Success | 200, 300, 303 | Execute | ✅ Yes | Optional |
| Error | 500 | Execute | ✅ Yes | Optional |
| NetworkError | 1001, 1002 | Log Only | ❌ No | Optional |
| Block | 301, 302 | Stop | ❌ No | Required |
| Close | 495-499 | Stop | ❌ No | Optional |
Why onError Executes Business Logic but onNetworkError Doesn't:
onError (Status Code 500) - Server Error:
- Scenario: NetFUNNEL server encounters internal errors
- Strategy: Execute business logic to maintain service availability
- Rationale: Server errors are typically temporary and shouldn't block user access
- Result: Robust service that continues even when NetFUNNEL has issues
onNetworkError (Status Code 1001, 1002) - Network Issues:
- Scenario: Network connectivity problems (offline, timeout)
- Strategy: Log only, don't execute business logic
- Rationale: Use
useNetworkRecoveryMode = truefor automatic network recovery - Result: Users stay in waiting room during network issues and auto-resume when connectivity returns
Network Recovery Mode Configuration:
Enable network recovery in your Application class for optimal network error handling:
- Kotlin
- Java
// SampleApplication.kt
Netfunnel.initialize(
clientId = "{{CLIENT_ID}}",
useNetworkRecoveryMode = true // Enable automatic network recovery
)
// SampleApplication.java
Netfunnel.INSTANCE.initialize(
"https://your-netfunnel-server.com",
"https://your-netfunnel-server.com/content/netfunnel-statics/assets/vwr-page/error/errorPage.html",
3000, // networkTimeout
0, // retryCount
false, // printLog
false, // errorBypass
true, // useNetfunnelTemplate
null, // userId
true, // useNetworkRecoveryMode
null // statusBarStyle
);
NetfunnelCompleteCallback
Purpose: Handle responses from NetFUNNEL server for stop functions.
Abstract Methods:
| Method | Required | Description |
|---|---|---|
onComplete | No | Called when key return is completed |
Example Implementation:
- Kotlin
- Java
import com.nf4.NetfunnelCompleteCallback
class StopCallback {
companion object {
private const val TAG = "NetFUNNEL"
}
private val callback = object : NetfunnelCompleteCallback() {
override fun onComplete(statusCode: Int, message: String) {
Log.d(TAG, "onComplete $statusCode $message")
/**
* Entry key return result processing logic
* ex - Navigate to next page when key return is successful
*/
handleKeyReturnCompletion()
}
}
fun getCallback(): NetfunnelCompleteCallback = callback
}
import com.nf4.NetfunnelCompleteCallback;
public class StopCallback {
private static final String TAG = "NetFUNNEL";
private final NetfunnelCompleteCallback callback = new NetfunnelCompleteCallback() {
@Override
public void onComplete(int statusCode, @NonNull String message) {
Log.d(TAG, "onComplete " + statusCode + " " + message);
/**
* Entry key return result processing logic
* ex - Navigate to next page when key return is successful
*/
handleKeyReturnCompletion();
}
};
public NetfunnelCompleteCallback getCallback() {
return callback;
}
}
Response Object Schema
The callback methods receive the following parameters:
| Parameter | Type | Description | Example |
|---|---|---|---|
statusCode | Int | HTTP status code | 200, 300, 500, 1001, etc. |
message | String | Response message | "Success", "Bypass", "Server Error", etc. |
aheadWait | Int | Users ahead in queue (onContinue only) | 5 |
behindWait | Int | Users behind in queue (onContinue only) | 10 |
waitTime | String | Estimated wait time (onContinue only) | "2 minutes" |
progressRate | Int | Progress percentage (onContinue only) | 75 |
Status Codes Reference
Complete reference for all possible status codes and their meanings.
| Status | StatusCode | Message | Description |
|---|---|---|---|
| Success | 200 | Success | Successfully passed the queue and entered the service. Normal queue passage. |
| 300 | Bypass | Entry bypassed due to various conditions. Examples: subscription/license expired, project/segment deactivated in console, errorBypass=true setting and error occurred. | |
| 303 | Express | Express entry succeeded. IP or ID registered in console whitelist (admin bypass). | |
| Error | 500 | Server Error | System error occurred. Examples: agent initialization function not called before start function, non-existent project/segment key used, segment deleted in console, server error causing partial response loss. |
| NetworkError | 1001 | Network Not Connected | Network connection blocked. WiFi/cellular data disabled. |
| 1002 | Network Timeout | Network timeout occurred. Examples: network latency, invalid waiting room HTML URL received, server down (502, etc.). | |
| Block | 301 | Block | Segment is in block state. Segment blocked in console (benevolent entry blocking). |
| 302 | Macro Block | User blocked. Examples: IP or ID registered in console blacklist (admin blocking), BotManager Basic enabled (malicious entry blocking). | |
| Close | 495 | Closed PostWaiting Room | Closed the post-waiting room. User clicked close button in post-waiting room. |
| 496 | Closed PreWaiting Room | Closed the pre-waiting room. User clicked close button in pre-waiting room. | |
| 497 | Closed Macro Blocking Room | Closed the macro blocking room. User clicked close button in macro blocking room. | |
| 498 | Closed Blocking Room | Closed the blocking room. User clicked close button in blocking room. | |
| 499 | Canceled Waiting Room | Clicked the cancel/close button in the standard waiting room. User clicked cancel button in standard waiting room. | |
| Continue | 201 | Continue | Waiting room update for custom template. Agent useNetfunnelTemplate=false setting and during basic waiting. |
Utility Functions
getVersion
Purpose: Get the current version of the NetFUNNEL Android Agent.
Function Signature:
- Kotlin
- Java
Netfunnel.getVersion(): String
Netfunnel.INSTANCE.getVersion(): String
Returns: String - The version string of the NetFUNNEL Android Agent
Example:
- Kotlin
- Java
val version = Netfunnel.getVersion()
Log.d("NetFUNNEL", "Agent version: $version")
String version = Netfunnel.INSTANCE.getVersion();
Log.d("NetFUNNEL", "Agent version: " + version);
Related Documentation
- Integration Methods Overview: Compare Basic Control vs Section Control approaches
- Basic Control Integration: Implementation guide with examples
- Section Control Integration: Implementation guide with examples
- Configuration Options: All initialization parameters
- Troubleshooting: Common issues and solutions