You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Open `MainActivity.java` class in **app\src\main\java\backtraceio\backtraceio** and replace `BacktraceCredential` constructor parameters with your `Backtrace endpoint URL` (e.g. https://xxx.sp.backtrace.io:6098) and `submission token`:
val backtraceCredentials =BacktraceCredentials("https://myserver.sp.backtrace.io:6097/", "4dca18e8769d0f5d10db0d1b665e64b3d716f76bf182fbcdad5d1d8070c12db0")
102
+
```
103
+
83
104
First start:
84
105
- Press `Run` and `Run..` or type keys combination `Alt+Shift+F10`.
85
106
- As module select `app` other options leave default.
@@ -91,11 +112,18 @@ First start:
91
112
92
113
First create a `BacktraceCredential` instance with your `Backtrace endpoint URL` (e.g. https://xxx.sp.backtrace.io:6098) and `submission token`, and supply it as a parameter in the `BacktraceClient` constructor:
val backtraceCredentials =BacktraceCredentials("https://myserver.sp.backtrace.io:6097/", "4dca18e8769d0f5d10db0d1b665e64b3d716f76bf182fbcdad5d1d8070c12db0")
124
+
val backtraceClient =BacktraceClient(applicationContext, backtraceCredentials)
125
+
```
126
+
99
127
## Sending an error report <aname="documentation-sending-report"></a>
100
128
101
129
Methods `BacktraceClient.send` and `BacktraceClient.sendAsync` will send an error report to the Backtrace endpoint specified. There `send` method is overloaded, see examples below:
@@ -105,9 +133,10 @@ Methods `BacktraceClient.send` and `BacktraceClient.sendAsync` will send an erro
105
133
106
134
The `BacktraceReport` class represents a single error report. (Optional) You can also submit custom attributes using the `attributes` parameter. <!--, or attach files by supplying an array of file paths in the `attachmentPaths` parameter.-->
107
135
136
+
Java
108
137
```java
109
138
try {
110
-
//throw exception here
139
+
//throw exception here
111
140
} catch (Exception exception) {
112
141
BacktraceReport report =newBacktraceReport(e,
113
142
newHashMap<String, Object>() {{
@@ -120,40 +149,76 @@ try {
120
149
}
121
150
```
122
151
152
+
Kotlin
153
+
```kotlin
154
+
try {
155
+
// throw exception here
156
+
}
157
+
catch (e:Exception) {
158
+
val report =BacktraceReport(e, mapOf("key" to "value"), listOf("file_path_1", "file_path_2"))
159
+
backtraceClient.send(report)
160
+
}
161
+
```
162
+
123
163
#### Asynchronous Send Support
124
164
125
165
Method `send` behind the mask use `AsyncTask` and wait until method `doInBackground` is not completed. Library gives you the option of not blocking code execution by using method `sendAsync` which returning the `AsyncTask<Void, Void, BacktraceResult>` object. Additionally, it is possible to specify the method that should be performed after completion `AsyncTask` by using events described in [events](#events).
val sendAsyncTask = backtraceClient.sendAsync(report)
178
+
// another code
179
+
val result = asynctask.get()
180
+
```
181
+
134
182
### Other BacktraceReport Overloads
135
183
136
184
`BacktraceClient` can also automatically create `BacktraceReport` given an exception or a custom message using the following overloads of the `BacktraceClient.send` or `BacktraceClient.sendAsync` methods:
All events are written in *listener* pattern. `BacktraceClient` allows you to attach your custom event handlers. For example, you can trigger actions before the `send` method:
0 commit comments