// If you stored the "default" account using setCurrentAccount(…) you can get the account by using the following line:
// If you stored the "default" account using setCurrentAccount(…) you can get the account by using the following line:
@@ -167,7 +167,7 @@ ssoAccount.token;
ssoAccount.url;
ssoAccount.url;
```
```
5) How to make a network request?
### 5) How to make a network request?
You'll notice that there is an callback parameter in the constructor of the `NextcloudAPI`.
You'll notice that there is an callback parameter in the constructor of the `NextcloudAPI`.
@@ -177,9 +177,9 @@ public NextcloudAPI(Context context, SingleSignOnAccount account, Gson gson, Api
You can use this callback to subscribe to errors that might occur during the initialization of the API. You can start making requests to the API as soon as you instantiated the `NextcloudAPI` object. For a minimal example to get started (without retrofit) take a look at section 5.2. The callback method `onConnected` will be called once the connection to the files app is established. You can start making calls to the api before that callback is fired as the library will queue your calls until the connection is established.
You can use this callback to subscribe to errors that might occur during the initialization of the API. You can start making requests to the API as soon as you instantiated the `NextcloudAPI` object. For a minimal example to get started (without retrofit) take a look at section 5.2. The callback method `onConnected` will be called once the connection to the files app is established. You can start making calls to the api before that callback is fired as the library will queue your calls until the connection is established.
5.1) **Using Retrofit**
#### 5.1) **Using Retrofit**
5.1.1) Before using this single sign on library, your interface for your retrofit API might look like this:
##### 5.1.1) Before using this single sign on library, your interface for your retrofit API might look like this:
```java
```java
publicinterfaceAPI{
publicinterfaceAPI{
@@ -212,7 +212,7 @@ public class ApiProvider {
}
}
```
```
5.1.2) Use of new API using the nextcloud app network stack
##### 5.1.2) Use of new API using the nextcloud app network stack
```java
```java
publicclassApiProvider{
publicclassApiProvider{
@@ -231,7 +231,7 @@ Enjoy! If you're already using retrofit, you don't need to modify your applicati
Note: If you need a different mapping between your json-structure and your java-structure you might want to create a custom type adapter using `new GsonBuilder().create().registerTypeAdapter(...)`. Take a look at [this](https://github.com/nextcloud/news-android/blob/783836390b4c27aba285bad1441b53154df16685/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/GsonConfig.java) example for more information.
Note: If you need a different mapping between your json-structure and your java-structure you might want to create a custom type adapter using `new GsonBuilder().create().registerTypeAdapter(...)`. Take a look at [this](https://github.com/nextcloud/news-android/blob/783836390b4c27aba285bad1441b53154df16685/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/GsonConfig.java) example for more information.
5.2) **Without Retrofit**
#### 5.2) **Without Retrofit**
`NextcloudAPI` provides a method called `performNetworkRequest(NextcloudRequest request)` that allows you to handle the server response yourself.
`NextcloudAPI` provides a method called `performNetworkRequest(NextcloudRequest request)` that allows you to handle the server response yourself.