Appxiom Issue Callback Listener - Code level Error Detection Notification
The Appxiom SDK provides a powerful callback listener system that enables real-time monitoring of all issues detected in your Android application. Use the Ax.listenForIssue() API to implement custom error handling, logging, or user notification systems.
Step 1: Register the Global Listener
Add the issue listener in your Application class onCreate() method. Register only a single global listener to receive callbacks for all issues detected by the SDK.
Application Class Implementation:
- Java
- Kotlin
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Initialize Appxiom SDK
Ax.init(this, appKey, platformKey);
// Register global issue listener
Ax.listenForIssue(new IssueFoundListener() {
@Override
public void issueFoundInBackgroundThread(IssueView issue) {
// Handle issue detection
handleIssueDetected(issue);
}
});
}
private void handleIssueDetected(IssueView issue) {
// Custom issue handling logic
Log.d("AppxiomIssue", "Issue detected: " + issue.getDetailedDescription());
// Switch to UI thread for UI operations
new Handler(Looper.getMainLooper()).post(() -> {
// Update UI or show notifications
showIssueNotification(issue);
});
}
}
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Appxiom SDK
Ax.init(this, appKey, platformKey)
// Register global issue listener
Ax.listenForIssue { issueView ->
// Handle issue detection
handleIssueDetected(issueView)
}
}
private fun handleIssueDetected(issue: IssueView?) {
issue?.let {
// Custom issue handling logic
Log.d("AppxiomIssue", "Issue detected: ${it.detailedDescription}")
// Switch to UI thread for UI operations
Handler(Looper.getMainLooper()).post {
// Update UI or show notifications
showIssueNotification(it)
}
}
}
}
Step 2: Implement Custom Issue Handling
The callback provides an IssueView object containing issue properties that are synchronized to the server, ensuring complete transparency in the monitoring process.
Important Threading Considerations:
- The callback executes in a background thread
- Use UI thread (Handler/runOnUiThread) for UI-related operations, if needed.
- The callback triggers immediately after issue occurrence
Comprehensive IssueView Field Reference
type
Data Type: byte | Availability: Mandatory for all issues
Identifies the specific type of issue detected. Each issue type has a unique code for easy categorization and handling.
Complete Issue Type Reference:
| Type | Category | Description | Documentation |
|---|---|---|---|
| 1 | Custom | Report Custom Issues | View Details |
| 2 | Function | Function returns Null | View Details |
| 3 | Function | Function returns value outside range | View Details |
| 4 | Function | Function returns unexpected boolean value | View Details |
| 5 | Performance | Delayed function execution | View Details |
| 6 | Performance | Screen loading delays | View Details |
| 7 | Feature | Track feature failures | View Details |
| 8 | — | Not Applicable for Android | — |
| 9 | Memory | Low memory warning | View Details |
| 10 | — | Not Applicable for Android | — |
| 11 | Crash | Crash Reporting | View Details |
| 12 | Exception | Report Exceptions | View Details |
| 13 | Network | Error in Status Code | View Details |
| 14 | Network | Exception during network call | View Details |
| 15 | Network | Delayed network call | View Details |
| 16 | — | Not Applicable for Android | — |
| 17 | Memory | Abnormal Memory Usage | View Details |
| 18 | Network | Duplicate network call | View Details |
| 19 | — | Not Applicable for Android | — |
| 20 | Memory | Spike in Memory Usage | View Details |
| 21 | Memory | Memory leaks | View Details |
| 22 | — | Not Applicable for Android | — |
| 23 | Performance | Frozen frames | View Details |
| 24 | Performance | Slow frames | View Details |
| 25 | ANR | ANR issues | View Details |
| 26 | — | Not Applicable for Android | — |
| 27 | ANR | Force close due to ANR | View Details |
| 28 | — | Not Applicable for Android | — |
| 29 | Startup | Cold App Startup delays | View Details |
| 30 | Startup | Warm App Startup delays | View Details |
| 31 | Startup | Hot App Startup delays | View Details |
severity
Data Type: byte | Availability: Mandatory
Indicates the severity level of the detected issue. Available severity levels:
- MINOR: Low impact issues
- MAJOR: Significant issues affecting functionality
- FATAL: Critical issues requiring immediate attention
detailedDescription
Data Type: String | Availability: Mandatory
Descriptive information about the specific event that triggered the issue.
occurrenceTime
Data Type: Long (UNIX Epoch) | Availability: Mandatory
Timestamp indicating when the issue occurred, expressed in milliseconds since the Unix epoch.
location
Data Type: String | Availability: Optional
Geographic or logical location where the issue occurred, useful for distributed applications or location-based debugging.
deviceState
Data Type: JSONObject | Availability: Mandatory
Comprehensive device state information including:
- Battery level
- Last reboot time
- Timezone offset
- Available memory
- Network connectivity status
customIdentifier
Data Type: String | Availability: Optional
Custom identifier set by the developer using the setCustomId API. Useful for user identification or session tracking. Learn more about custom identifiers.
activityTrail
Data Type: JSONArray | Availability: Optional
Chronologically ordered list of lifecycle events and custom markers, providing context for issue occurrence. Learn more about activity trail.
functionId
Data Type: String | Availability: Optional (Function and Feature tracking)
Function identifier specified in the @AX annotation for function and feature tracking, if set by developer.
functionName
Data Type: String | Availability: Optional (Function and Feature tracking)
Name of the function where the issue occurred, if available in function and feature tracking.
nextFunctionId
Data Type: String | Availability: Optional (Function and Feature tracking)
For feature tracking, the identifier of the next function in the chain, as specified in the @AX annotation.
functionParameters
Data Type: JSONArray | Availability: Optional (Function and Feature tracking)
Parameters passed to the tracked function when the issue occurred.
returnValue
Data Type: String | Availability: Optional (Function and Feature tracking)
The return value of the tracked function when the issue was detected.
returnValueType
Data Type: String | Availability: Optional (Function and Feature tracking)
Data type of the function's return value.
returnValueSize
Data Type: Long | Availability: Optional (Function and Feature tracking)
Size of the return value in bytes for tracked functions.
url
Data Type: String | Availability: Optional (Network issues)
The URL of the API call when a network-related issue occurred.
method
Data Type: byte | Availability: Optional (Network issues)
HTTP method used for the network request (GET, POST, PUT, DELETE, etc.).
statusCode
Data Type: short | Availability: Optional (Network issues)
HTTP status code returned by the server for network-related issues.
networkParameters
Data Type: JSONObject | Availability: Optional (Network issues)
Detailed network information may include:
- Request and response headers
- Request and response body
- Status codes
- Timing information
stacktrace
Data Type: String | Availability: Optional (Crash and Exception issues)
Complete stack trace for crashes, ANRs, and exception-related issues.
exceptionType
Data Type: String | Availability: Optional (Crash and Exception issues)
Type of exception that caused the issue (e.g., NullPointerException, OutOfMemoryError).
exceptionLineNumber
Data Type: int | Availability: Optional (Crash and Exception issues)
Line number in the source code where the exception occurred, if available.
eventStartTime
Data Type: Long (UNIX Epoch) | Availability: Optional
Start time of the event that caused the issue, particularly useful for network calls and function tracking.
eventEndTime
Data Type: Long (UNIX Epoch) | Availability: Optional
End time of the event, particularly useful for network calls and function tracking.
expectedExecutionTime
Data Type: Long | Availability: Optional
Expected execution time set by the developer in the @AX annotation for feature tracking.
timerTime
Data Type: Long (UNIX Epoch) | Availability: Optional
Timer-related timestamp for issues involving time-based operations or delays.
timered
Data Type: boolean | Availability: Optional
Flag indicating whether the issue is related to timer-based operations or time-sensitive functionality.
Frequently Asked Questions (FAQ)
Q: How do I register an issue callback listener in my Android app?
A: Register the listener in your Application class onCreate() method using Ax.listenForIssue(). Only register one global listener to receive callbacks for all detected issues.
Q: Can I register multiple issue listeners in different parts of my app?
A: It's recommended to use only one global listener in your Application class. You can then distribute issue notifications to different parts of your app from this central listener.
Q: What thread does the issue callback execute on?
A: The callback executes on a background thread. Use Handler(Looper.getMainLooper()).post() or runOnUiThread() for any UI operations within the callback.
Q: When exactly is the issue callback triggered?
A: The callback triggers immediately after an issue is detected by the SDK, providing real-time notification of problems in your application.
Q: How can I filter issues by type in my callback listener?
A: Use the type field in the IssueView object to filter issues:
- Java
- Kotlin
if (issue.getType() == 11) { // Crash issues
handleCrashIssue(issue);
} else if (issue.getType() == 25) { // ANR issues
handleANRIssue(issue);
}
when (issue.type) {
11.toByte() -> { // Crash issues
handleCrashIssue(issue)
}
25.toByte() -> { // ANR issues
handleANRIssue(issue)
}
}
Q: What information is available for network-related issues?
A: Network issues provide URL, HTTP method, status code, request/response headers and body, and timing information through the networkParameters field.
Q: How do I access custom data I've set for issue tracking?
A: Use the customIdentifier field to access custom IDs set via setCustomId() API, and activityTrail for custom activity markers set via setActivityMarker().
Q: Can I get stack traces for all types of issues?
A: Stack traces are available for crashes, ANRs, and exception-related issues through the stacktrace field. Other issue types may not include stack trace information.
Q: How can I determine if an issue is related to memory problems?
A: Check for issue types 9 (low memory), 17 (abnormal memory usage), 20 (memory spikes), and 21 (memory leaks).
Q: What additional context is available for network issues?
A: Network issues provides URL, HTTP method, status code, and comprehensive network parameters in the networkParameters JSONObject based on availability.
Q: My callback receives too many issues. How can I reduce noise?
A: Filter issues by severity level or type in your callback implementation.
Q: Can I test the issue callback without waiting for real issues?
A: Yes, use Ax.test() to generate a test issue that will trigger your callback listener for testing purposes.