### Start Spotify Authentication Activity (Java) Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/com/spotify/sdk/android/auth/app/SpotifyNativeAuthUtil.html This instance method initiates the Spotify authentication flow. It is part of the SpotifyNativeAuthUtil class and returns a boolean indicating whether the authentication activity was successfully started. ```java public boolean startAuthActivity() { // Implementation details to start the auth activity } ``` -------------------------------- ### Spotify App Installation Check Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Checks if the Spotify application is installed on the device. ```APIDOC ## GET /spotify/android-sdk/app/is-installed ### Description Checks if the Spotify app is installed on the current device. ### Method GET ### Endpoint /spotify/android-sdk/app/is-installed ### Parameters #### Query Parameters - **context** (Context) - Required - The application context. ### Response #### Success Response (200) - **isInstalled** (boolean) - True if Spotify is installed, false otherwise. #### Response Example ```json { "isInstalled": true } ``` ``` -------------------------------- ### SpotifyAppRemote - Connect Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/android/appremote/api/SpotifyAppRemote.html Establishes a connection to the Spotify app to get an instance of SpotifyAppRemote. This is the entry point for all interactions. ```APIDOC ## POST /connect ### Description Connect to get an instance of SpotifyAppRemote. This method establishes a connection to the Spotify app, allowing your application to interact with it. ### Method POST ### Endpoint /connect ### Parameters #### Query Parameters - **context** (android.content.Context) - Required - The Android context. - **params** (com.spotify.android.appremote.api.ConnectionParams) - Required - Parameters for the connection, including client ID and redirect URI. - **connectionListener** (com.spotify.android.appremote.api.Connector.ConnectionListener) - Required - A listener to handle connection events (success, failure, disconnection). ### Request Example ```json { "context": "", "params": { "clientId": "your_client_id", "redirectUri": "your_redirect_uri" }, "connectionListener": "" } ``` ### Response #### Success Response (200) - **spotifyAppRemote** (com.spotify.android.appremote.api.SpotifyAppRemote) - An instance of SpotifyAppRemote to interact with the Spotify app. #### Response Example ```json { "spotifyAppRemote": "" } ``` ``` -------------------------------- ### ContentApi - Play Content Item Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Starts playback of a playable ListItem. This functionality requires FEATURES_V1. ```APIDOC ## POST /spotify/android-sdk/content/play ### Description Starts playback of a playable ListItem. ### Method POST ### Endpoint /spotify/android-sdk/content/play ### Parameters #### Request Body - **listItem** (ListItem) - Required - The playable item to start playback. ### Request Example ```json { "listItem": { "id": "spotify:track:12345", "title": "Example Song", "uri": "spotify:track:12345" } } ``` ### Response #### Success Response (200) - **message** (string) - Indicates successful playback initiation. #### Response Example ```json { "message": "Playback started successfully." } ``` ``` -------------------------------- ### Check Spotify Installation - Java Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/android/appremote/api/SpotifyAppRemote.html Checks if the Spotify app is currently installed on the Android device. Requires a valid Android context as input. ```java boolean isInstalled = AppRemote.isSpotifyInstalled(context); ``` -------------------------------- ### LoginActivity Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs-store/com/spotify/sdk/android/auth/LoginActivity.html The LoginActivity class manages the login flow for the Spotify SDK. It should be invoked using AuthorizationClient.openLoginActivity and not started directly. ```APIDOC ## Class LoginActivity ### Description The activity that manages the login flow. It should not be started directly. Instead use [`AuthorizationClient.openLoginActivity(android.app.Activity, int, AuthorizationRequest)`](AuthorizationClient.html#openLoginActivity(android.app.Activity,int,com.spotify.sdk.android.auth.AuthorizationRequest)) ### Method N/A (This is a class description, not an endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Fields ### Field Summary * `static int REQUEST_CODE` * `static java.lang.String REQUEST_KEY` * `static java.lang.String RESPONSE_KEY` ### Fields inherited from class android.app.Activity `DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK` ### Fields inherited from class android.content.Context N/A ``` -------------------------------- ### Configure Redirect URI Scheme and Host in Gradle Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/README.md This code demonstrates how to configure the redirect URI scheme and host within your app's `build.gradle` file, which is required for Spotify authentication since version 2.0.0. The example uses 'spotify-sdk' as the scheme and 'auth' as the host. ```gradle defaultConfig { manifestPlaceholders = [redirectSchemeName: "spotify-sdk", redirectHostName: "auth"] ... } ``` -------------------------------- ### Play Content Item Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/android/appremote/api/ContentApi.html Starts playback of a playable content list item. This method requires FEATURES_V1. ```APIDOC ## POST /spotify/android-sdk/ContentApi/play ### Description Start playback of a playable ListItem. ### Method POST ### Endpoint /spotify/android-sdk/ContentApi/play ### Parameters #### Request Body - **item** (ListItem) - Required - The ListItem to play. It must be playable. ### Request Example ```json { "item": { "title": "Song Title", "uri": "spotify:track:12345", "playable": true } } ``` ### Response #### Success Response (200) - **callResult** (CallResult) - A pending call result that can be used to track the success or failure of the playback command. #### Response Example ```json { "callResult": {} } ``` ``` -------------------------------- ### AuthorizationHandler and SpotifyAuthHandler Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs-store/index-all.html Documentation for the AuthorizationHandler interface and its implementation SpotifyAuthHandler, including starting and stopping the authorization process. ```APIDOC ## AuthorizationHandler and SpotifyAuthHandler ### Description Provides methods to initiate and terminate the Spotify authorization flow. `AuthorizationHandler` is an interface, and `SpotifyAuthHandler` is a concrete implementation used within the app. ### Method ``` AuthorizationHandler.start(Activity activity, AuthorizationRequest request) SpotifyAuthHandler.start(Activity activity, AuthorizationRequest request) AuthorizationHandler.stop() SpotifyAuthHandler.stop() ``` ### Endpoint N/A (Class/Interface methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java // Example for starting authorization AuthorizationRequest request = \ new AuthorizationRequest.Builder(CLIENT_ID, AuthorizationResponse.Type.CODE) .setRedirectUri(REDIRECT_URI) .setScopes(new String[]{"playlist-read-private", "user-modify-playback-state"}) .build(); AuthorizationHandler.start(this, request); // or SpotifyAuthHandler.start(this, request); ``` ### Response #### Success Response (200) N/A (These methods initiate a process that leads to a callback.) #### Response Example N/A ``` -------------------------------- ### Start Spotify Authorization Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs-store/com/spotify/sdk/android/auth/store/PlayStoreHandler.html Initiates the Spotify authorization flow. This method requires an Activity context and an AuthorizationRequest object. It's part of the AuthorizationHandler interface. ```java public void start(android.app.Activity activity, com.spotify.sdk.android.auth.AuthorizationRequest request) ``` -------------------------------- ### Get Recommended Content Items Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/android/appremote/api/ContentApi.html Retrieves a list of recommended content items based on a specified content type. This method requires FEATURES_V1. ```APIDOC ## GET /spotify/android-sdk/ContentApi ### Description Get a list of recommended content items for a given content type. ### Method GET ### Endpoint /spotify/android-sdk/ContentApi ### Parameters #### Query Parameters - **type** (String) - Required - The type of content to fetch. Refer to `ContentApi.ContentType` for possible values. ### Request Example ```json { "type": "playlist" } ``` ### Response #### Success Response (200) - **callResult** (CallResult) - A pending call result containing a list of recommended content items. #### Response Example ```json { "callResult": { "items": [ { "title": "Example Playlist", "uri": "spotify:playlist:12345", "playable": true } ] } } ``` ``` -------------------------------- ### Open Spotify Download Page (Java) Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/com/spotify/sdk/android/auth/AuthorizationClient.html Opens the Spotify download page in the Play Store or a web browser. This method is useful for directing users to install Spotify if it's not already on their device. It requires an activity context to initiate the intent. ```java public static void openDownloadSpotifyActivity(android.app.Activity contextActivity) ``` -------------------------------- ### Activity Lifecycle Methods for Spotify SDK Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/com/spotify/sdk/android/auth/LoginActivity.html Standard Android Activity lifecycle methods overridden for use with the Spotify SDK. These include onCreate for initialization, onDestroy for cleanup, and onActivityResult for handling results from started activities, such as the Spotify authorization flow. These methods are crucial for managing the SDK's state within an Android application. ```java protected void onCreate(android.os.Bundle savedInstanceState) Overrides: `onCreate` in class `android.app.Activity` ``` ```java protected void onDestroy() Overrides: `onDestroy` in class `android.app.Activity` ``` ```java protected void onActivityResult(int requestCode, int resultCode, android.content.Intent intent) Overrides: `onActivityResult` in class `android.app.Activity` ``` -------------------------------- ### Java: SpotifyAuthHandler.start Method Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/com/spotify/sdk/android/auth/app/SpotifyAuthHandler.html Starts the Spotify authorization flow. This method takes an Android Activity and an AuthorizationRequest object as input and returns a boolean indicating success or failure. ```java public boolean start(android.app.Activity contextActivity, com.spotify.sdk.android.auth.AuthorizationRequest request) ``` -------------------------------- ### Initialize AuthorizationResponse.Builder Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/com/spotify/sdk/android/auth/AuthorizationResponse.Builder.html Constructs a new AuthorizationResponse.Builder instance. This is the starting point for creating an AuthorizationResponse object. No specific dependencies or input parameters are required for this constructor. ```java public AuthorizationResponse.Builder() ``` -------------------------------- ### HelloDetails Constructor - Java Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/protocol/types/HelloDetails.html The constructor for the HelloDetails class initializes an instance with roles, info, authentication methods, authentication ID, and extra parameters. It is used to create objects representing connection details. ```Java public HelloDetails(Roles roles, Info info, java.lang.String[] authmethods, java.lang.String authid, java.util.Map extras) ``` -------------------------------- ### FallbackHandlerProvider Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs-store/index-all.html Provides an AuthorizationHandler that guides users to the Play Store if the Spotify app is not installed. ```APIDOC ## Fallback Handler Provider ### Description The `FallbackHandlerProvider` class offers an `AuthorizationHandler` implementation. This handler is designed to gracefully manage situations where the Spotify application is not present on the user's device by directing them to the Google Play Store to download it. ### Class: FallbackHandlerProvider #### Constructor - **FallbackHandlerProvider()**: Initializes a new instance of the `FallbackHandlerProvider` class. ### Usage Example ```java // Obtain an AuthorizationHandler that falls back to the Play Store AuthorizationHandler handler = new FallbackHandlerProvider().getHandler(context); // Use the handler to initiate the authorization flow // handler.startAuth(...); ``` ``` -------------------------------- ### Get Spotify Authorization Intent (Java) Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs-store/com/spotify/sdk/android/auth/LoginActivity.html Generates an Intent to start the Spotify authorization flow. Requires an Android Activity context and an AuthorizationRequest object. Returns an Intent that should be launched using startActivityForResult. ```java public static android.content.Intent getAuthIntent(android.app.Activity contextActivity, com.spotify.sdk.android.auth.AuthorizationRequest request) ``` -------------------------------- ### LoginActivity Methods Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs-store/com/spotify/sdk/android/auth/LoginActivity.html Details on the specific methods available in the LoginActivity class, including overrides. ```APIDOC ## Method Detail ### onNewIntent `protected void onNewIntent(android.content.Intent intent)` Overrides: `onNewIntent` in class `android.app.Activity` ``` -------------------------------- ### hashCode() Method Documentation Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Documentation for the hashCode() method across different types in the com.spotify.protocol.types package. ```APIDOC ## Method hashCode() ### Description Calculates and returns the hash code value for the object. This method is overridden in various classes within the `com.spotify.protocol.types` package to provide a unique hash code for each object instance. ### Method `hashCode()` ### Endpoint N/A (Instance method) ### Parameters None ### Request Example N/A ### Response #### Success Response (200) - **hashCode** (int) - The hash code value for the object. #### Response Example ``` 123456789 ``` ### Classes with hashCode() method: - Identifier - Image - ImageIdentifier - ImageUri - Info - LibraryState - ListItem - ListItems - Message - MotionState - PlaybackSpeed - PlayerContext - PlayerOptions - PlayerRestrictions - PlayerState - Repeat - Roles - Shuffle - Track - Types.RequestId - Types.SubscriptionId - Uri - Uriss ``` -------------------------------- ### Retrieve All AuthorizationResponse.Type Enum Constants Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/com/spotify/sdk/android/auth/AuthorizationResponse.Type.html Provides a method to get an array of all defined constants within the AuthorizationResponse.Type enum. This is useful for iterating through all possible response types, for example, in testing or logging scenarios. ```Java public static AuthorizationResponse.Type[] values() // Returns an array containing the constants of this enum type, in the order they are declared. // Example usage: for (AuthorizationResponse.Type c : AuthorizationResponse.Type.values()) System.out.println(c); ``` -------------------------------- ### SpotifyAppRemote Class Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Provides methods for connecting to and interacting with Spotify. ```APIDOC ## Class: SpotifyAppRemote ### Description Provides static methods for connecting to the Spotify application and accessing its features via the App Remote SDK. ### Methods - **isConnected()** (boolean): Returns true if the connection to the Spotify app is established, false otherwise. - **isDebugMode()** (boolean): Returns true if debug mode is enabled for the SDK, false otherwise. - **getImagesApi()** (ImagesApi): Returns an instance of the ImagesApi for retrieving images. ### Example Usage ```java if (SpotifyAppRemote.isConnected()) { // App is connected } if (SpotifyAppRemote.isDebugMode()) { // Debug mode is on } ImagesApi imagesApi = SpotifyAppRemote.getImagesApi(); ``` ``` -------------------------------- ### Get Authorization Intent for Spotify SDK Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/com/spotify/sdk/android/auth/LoginActivity.html Initiates the authorization flow for the Spotify SDK. It requires an Android Activity context and an AuthorizationRequest object. The method returns an Android Intent that should be used to start the authorization activity. No specific output or input types are mentioned beyond the parameters. ```java public static android.content.Intent getAuthIntent(android.app.Activity contextActivity, AuthorizationRequest request) ``` -------------------------------- ### LoginActivity Constructor Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs-store/com/spotify/sdk/android/auth/LoginActivity.html Details on the constructor for the LoginActivity class. ```APIDOC ## Constructor Detail ### LoginActivity `public LoginActivity()` ``` -------------------------------- ### UserApi - Instance Methods Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/android/appremote/api/UserApi.html This section details the instance methods available in the UserApi for interacting with user data. ```APIDOC ## POST /spotify/android-sdk/UserApi/addToLibrary ### Description Adds an item to the user's library. ### Method POST ### Endpoint /spotify/android-sdk/UserApi/addToLibrary ### Parameters #### Path Parameters - **uri** (string) - Required - The Spotify URI of the item to add. ### Request Example { "uri": "spotify:track:example_track_id" } ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example { "status": "success" } ``` ```APIDOC ## GET /spotify/android-sdk/UserApi/getCapabilities ### Description Retrieves the capabilities of the current user. ### Method GET ### Endpoint /spotify/android-sdk/UserApi/getCapabilities ### Parameters (No parameters required for this endpoint) ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **capabilities** (Capabilities) - An object containing the user's capabilities. #### Response Example { "capabilities": { "canPlayOnDemand": true, "canTransferPlayback": true } } ``` ```APIDOC ## GET /spotify/android-sdk/UserApi/getLibraryState ### Description Gets the library state for a given Spotify URI. ### Method GET ### Endpoint /spotify/android-sdk/UserApi/getLibraryState ### Parameters #### Query Parameters - **uri** (string) - Required - The Spotify URI to check the library state for. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **libraryState** (LibraryState) - An object indicating if the item is in the user's library. #### Response Example { "libraryState": { "isAdded": true } } ``` ```APIDOC ## POST /spotify/android-sdk/UserApi/removeFromLibrary ### Description Removes an item from the user's library. ### Method POST ### Endpoint /spotify/android-sdk/UserApi/removeFromLibrary ### Parameters #### Path Parameters - **uri** (string) - Required - The Spotify URI of the item to remove. ### Request Example { "uri": "spotify:track:example_track_id" } ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example { "status": "success" } ``` ```APIDOC ## POST /spotify/android-sdk/UserApi/subscribeToCapabilities ### Description Subscribes to changes in the user's capabilities. This provides real-time updates. ### Method POST ### Endpoint /spotify/android-sdk/UserApi/subscribeToCapabilities ### Parameters (No parameters required for this endpoint) ### Request Example (No request body for POST requests that are subscriptions) ### Response #### Success Response (200) - **subscription** (Subscription) - A subscription object that will deliver updates to the user's capabilities. #### Response Example { "subscription": { "id": "sub_12345" } } ``` ```APIDOC ## POST /spotify/android-sdk/UserApi/subscribeToUserStatus ### Description Subscribes to changes in the user's status. This provides real-time updates on the user's state. ### Method POST ### Endpoint /spotify/android-sdk/UserApi/subscribeToUserStatus ### Parameters (No parameters required for this endpoint) ### Request Example (No request body for POST requests that are subscriptions) ### Response #### Success Response (200) - **subscription** (Subscription) - A subscription object that will deliver updates to the user's status. #### Response Example { "subscription": { "id": "sub_67890" } } ``` -------------------------------- ### Player API - Get Player State Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Gets the current player state of the Spotify app. ```APIDOC ## GET /spotify/android-sdk/player/state ### Description Gets the current player state of the Spotify app. ### Method GET ### Endpoint /spotify/android-sdk/player/state ### Parameters #### Query Parameters - **None** ### Request Example ```json {} ``` ### Response #### Success Response (200) - **playerState** (object) - The current state of the Spotify player. #### Response Example ```json { "playerState": { "track": { "uri": "spotify:track:12345", "name": "Song Title", "artist": { "name": "Artist Name" } }, "position": 120000, "isPaused": false } } ``` ``` -------------------------------- ### Check if Spotify is Installed (Java) Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/com/spotify/sdk/android/auth/app/SpotifyNativeAuthUtil.html This method checks if a version of the main Spotify application is installed on the device. It takes an Android Context as input and returns a boolean indicating whether Spotify is installed. ```java public static boolean isSpotifyInstalled(@NonNull android.content.Context context) { // Implementation details to check for Spotify installation } ``` -------------------------------- ### AuthorizationClient Methods Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/index-all.html Provides methods for initiating the Spotify authorization process, including opening the login activity or a browser-based flow, and handling scenarios where Spotify needs to be downloaded. ```APIDOC ## AuthorizationClient ### Description This class provides static methods to initiate the Spotify authorization process within an Android application. ### Methods #### openDownloadSpotifyActivity ##### Description Opens Spotify in the Play Store or browser. This method is useful if the user does not have Spotify installed. ##### Method `static void openDownloadSpotifyActivity(Activity activity)` ##### Parameters - **activity** (Activity) - The current activity context. #### openDownloadSpotifyActivity ##### Description Opens Spotify in the Play Store or browser with an optional referrer string. This overload allows for tracking the source of the download. ##### Method `static void openDownloadSpotifyActivity(Activity activity, String referrer)` ##### Parameters - **activity** (Activity) - The current activity context. - **referrer** (String) - An optional string to identify the referrer. #### openLoginActivity ##### Description Opens the LoginActivity, which performs the authorization flow. This is typically used for in-app login. ##### Method `static void openLoginActivity(Activity activity, int requestCode, AuthorizationRequest request)` ##### Parameters - **activity** (Activity) - The current activity context. - **requestCode** (int) - The request code to identify this login attempt in `onActivityResult`. - **request** (AuthorizationRequest) - The authorization request object containing scopes and other parameters. #### openLoginInBrowser ##### Description Triggers an intent to open the Spotify accounts service in a browser. This is useful for a web-based login flow. ##### Method `static void openLoginInBrowser(Activity activity, AuthorizationRequest request)` ##### Parameters - **activity** (Activity) - The current activity context. - **request** (AuthorizationRequest) - The authorization request object containing scopes and other parameters. ``` -------------------------------- ### GET /spotify/android-sdk/libraryState Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/android/appremote/api/UserApi.html Gets the library state for a given Spotify URI (track or album). This endpoint requires FEATURES_V1. ```APIDOC ## GET /spotify/android-sdk/libraryState ### Description Gets the library state for a given Spotify URI (track or album). Supported URIs currently include: Track - example: spotify:track:6rqhFgbbKwnb9MLmUQDhG6 Album - example: spotify:album:2VYSDvc0ZdcfkXDcYVjHs6. Introduced in `com.spotify.protocol.client.RequiredFeatures#FEATURES_V1`. ### Method GET ### Endpoint /spotify/android-sdk/libraryState ### Parameters #### Query Parameters - **uri** (string) - Required - The track or album URI to get library state for. ### Request Example ```json { "uri": "spotify:track:6rqhFgbbKwnb9MLmUQDhG6" } ``` ### Response #### Success Response (200) - **LibraryState** (object) - The library state of the given URI. #### Response Example ```json { "isSaved": true } ``` ``` -------------------------------- ### HelloDetails Methods - Java Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/protocol/types/HelloDetails.html Provides the standard object methods for the HelloDetails class: equals, hashCode, and toString. These methods are essential for object comparison, hash-based data structures, and string representation. ```Java public boolean equals(java.lang.Object o) public int hashCode() public java.lang.String toString() ``` -------------------------------- ### Check Spotify App Installation (Java) Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/com/spotify/sdk/android/auth/app/SpotifyNativeAuthUtil.html Determines if any version of the Spotify main application is currently installed on the device. It requires the Android context to perform the check. Returns true if an app is installed, and false otherwise. This is a utility function for integrating with the Spotify app. ```java public boolean isSpotifyInstalled(Context context) { // Implementation to check for Spotify app installation // Uses PackageManager to query for the Spotify app signature or package name. // Returns true if found, false otherwise. return false; // Placeholder } ``` -------------------------------- ### SpotifyAppRemote - Entry Point Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/android/appremote/api/package-summary.html The SpotifyAppRemote class is the main entry point for interacting with the Spotify app using the App Remote SDK for Android. ```APIDOC ## SpotifyAppRemote ### Description Entry point for interacting with the Spotify app using the Spotify App Remote for Android. ### Class com.spotify.android.appremote.api.SpotifyAppRemote ### Methods - `getConnectApi()`: Get an instance of a ConnectApi. - `getContentApi()`: Get an instance of a ContentApi. - `getImagesApi()`: Get an instance of an ImagesApi. - `getUserApi()`: Get an instance of an UserApi. ``` -------------------------------- ### Check if Spotify App is Installed Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/com/spotify/sdk/android/auth/app/SpotifyNativeAuthUtil.html This method checks if a version of the Spotify main application is installed on the device. It uses the provided context to perform the check. ```APIDOC ## Check if Spotify App is Installed ### Description Checks if a version of the Spotify main application is installed. ### Method GET (or equivalent for checking installation status) ### Endpoint `/spotify/android-sdk/isSpotifyInstalled` ### Parameters #### Query Parameters - **context** (Context) - Required - The context of the caller, used to check if the app is installed. ### Response #### Success Response (200) - **isInstalled** (boolean) - True if a Spotify app is installed, false otherwise. #### Response Example ```json { "isInstalled": true } ``` ``` -------------------------------- ### ImageUri Class Documentation Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/protocol/types/ImageUri.html Detailed documentation for the ImageUri class, including its fields, constructor, and methods. ```APIDOC ## Class ImageUri **Package:** com.spotify.protocol.types **Extends:** java.lang.Object **Implements:** Item ### Description The ImageUri class represents a URI for an image within the Spotify ecosystem. ### Fields * **raw** (String) - The raw string representation of the image URI. This field is nullable. ### Constructor * **ImageUri(String raw)** * Description: Constructs a new ImageUri object with the provided raw URI string. * Parameters: * **raw** (String) - The raw image URI. ### Methods * **equals(Object o)** (boolean) * Description: Compares this ImageUri object with another object for equality. Overrides the default Object.equals method. * **hashCode()** (int) * Description: Returns a hash code value for this ImageUri object. Overrides the default Object.hashCode method. * **toString()** (String) * Description: Returns a string representation of this ImageUri object. Overrides the default Object.toString method. ### Examples #### Constructor Example ```java String imageUrl = "spotify:image:abc123xyz"; ImageUri imageUri = new ImageUri(imageUrl); ``` #### Usage Example ```java String uriString = imageUri.toString(); // Returns "spotify:image:abc123xyz" boolean areEqual = imageUri.equals(anotherImageUri); int hash = imageUri.hashCode(); ``` ``` -------------------------------- ### Login Dialog and Activity Lifecycle Methods Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/index-all.html Documentation for lifecycle methods within `LoginDialog` and `LoginActivity`, relevant for managing the UI and state of the authorization process. ```APIDOC ## Login Dialog and Activity Lifecycle ### Description This section details specific lifecycle methods for the `LoginDialog` and `LoginActivity` classes, which are part of the Spotify Android SDK's authentication flow. ### Classes and Methods #### LoginDialog ##### onCreate(Bundle) - **Description**: Called when the dialog is first created. - **Method**: `onCreate(Bundle savedInstanceState)` ##### onDetachedFromWindow() - **Description**: Called when the dialog is detached from its window. - **Method**: `onDetachedFromWindow()` ##### onStop() - **Description**: Called when the dialog is no longer visible to the user. - **Method**: `onStop()` #### LoginActivity ##### onCreate(Bundle) - **Description**: Called when the activity is first created. - **Method**: `onCreate(Bundle savedInstanceState)` ##### onDestroy() - **Description**: Called before the activity is destroyed. - **Method**: `onDestroy()` ##### onNewIntent(Intent) - **Description**: Called when the activity receives a new intent. This can happen if the activity is launched in a singleTask mode and receives another launch intent. - **Method**: `onNewIntent(Intent intent)` ``` -------------------------------- ### AuthorizationClient - Login Activity Intent Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/index-all.html Provides a method to get an intent for opening the LoginActivity. ```APIDOC ## AuthorizationClient ### Description Client for initiating and handling Spotify authorization. ### Static Method - **createLoginActivityIntent(Activity, AuthorizationRequest)**: Get an intent to open the LoginActivity. ``` -------------------------------- ### HelloDetails Class Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/protocol/types/HelloDetails.html Documentation for the HelloDetails class, which represents details about a connection or session in the Spotify App Remote SDK. ```APIDOC ## HelloDetails Class ### Description Represents details about a connection or session, including authentication information, roles, and extra data. ### Fields - **authid** (String) - The authentication ID. - **authmethods** (String[]) - An array of supported authentication methods. - **extras** (Map) - A map of additional key-value pairs for extra information. - **info** (Info) - An object containing general information. - **roles** (Roles) - An object representing the roles associated with the connection. ### Constructor - **HelloDetails**(Roles roles, Info info, String[] authmethods, String authid, Map extras) - Constructs a new HelloDetails object with the specified roles, info, authentication methods, authentication ID, and extras. ### Methods - **equals**(Object o) (boolean) - Indicates whether some other object is "equal to" this one. - **hashCode**() (int) - Returns a hash code value for the object. - **toString**() (String) - Returns a string representation of the object. ### Inherited Methods (from Object) - getClass - notify - notifyAll - wait - wait - wait ``` -------------------------------- ### PlayerApi - Get Stream Type Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Retrieves the current stream type of the Spotify app player. ```APIDOC ## GET /spotify/android-sdk/player/streamtype ### Description Retrieves the current stream type of the Spotify app player. ### Method GET ### Endpoint /spotify/android-sdk/player/streamtype ### Parameters None ### Request Example None ### Response #### Success Response (200) - **streamType** (StreamType) - The current stream type (e.g., AUDIO, VIDEO). #### Response Example ```json { "streamType": "AUDIO" } ``` ``` -------------------------------- ### ImagesApi Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Provides methods to get images from the Spotify App. An instance can be obtained using SpotifyAppRemote.getImagesApi(). ```APIDOC ## GET /spotify/android-sdk/images ### Description Retrieves images from the Spotify App. ### Method GET ### Endpoint /spotify/android-sdk/images ### Parameters #### Query Parameters - **type** (ImageType) - Required - The type of image to retrieve. ### Request Example (No request body for GET) ### Response #### Success Response (200) - **images** (List) - A list of image URIs. #### Response Example ```json { "images": [ { "uri": "spotify:image:abcdef1234567890" } ] } ``` ``` -------------------------------- ### User API - Get Library State Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Retrieves the library state for a given Spotify URI. ```APIDOC ## GET /spotify/android-sdk/library/{spotifyUri} ### Description Gets the library state for the given Spotify URI. ### Method GET ### Endpoint /spotify/android-sdk/library/{spotifyUri} ### Parameters #### Path Parameters - **spotifyUri** (String) - Required - The Spotify URI for which to retrieve the library state. #### Query Parameters - **None** ### Request Example ```json {} ``` ### Response #### Success Response (200) - **libraryState** (object) - The library state for the given URI. #### Response Example ```json { "libraryState": { "isSaved": true } } ``` ``` -------------------------------- ### WelcomeDetails Class and Constructor Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Defines the WelcomeDetails class and its constructor for handling user roles. ```APIDOC ## WelcomeDetails Class and Constructor ### Description Represents details related to user welcome, potentially including roles. The constructor initializes WelcomeDetails with a specified set of roles. ### Method Constructor ### Endpoint N/A (Class constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java // Assuming Roles is a defined class or interface Roles userRoles = new Roles(...); WelcomeDetails welcomeDetails = new WelcomeDetails(userRoles); ``` ### Response #### Success Response (200) - **WelcomeDetails Object** - An instance of the WelcomeDetails class. #### Response Example ```java // Represents a WelcomeDetails object with specific roles WelcomeDetails welcomeDetails = new WelcomeDetails(new Roles(...)); ``` ``` -------------------------------- ### Uri and related classes toString() methods Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Documentation for the `toString()` method in various classes within the `com.spotify.protocol.types` package, including `Uri`, `Uris`, `UriWithOptionExtras`, `UserStatus`, and `WelcomeDetails`. ```APIDOC ## GET /spotify/android-sdk/uri/toString ### Description Provides the string representation of a Spotify URI. ### Method GET ### Endpoint /spotify/android-sdk/uri/toString ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **uri_string** (string) - The string representation of the Spotify URI. #### Response Example { "uri_string": "spotify:track:12345" } ``` -------------------------------- ### PlayerContext - Get Player Context Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Retrieves the current context of the Spotify player, such as an album or playlist, and its metadata. ```APIDOC ## GET /spotify/android-sdk/player/context ### Description Retrieves the current context of the Spotify player, such as an album or playlist, and its metadata. ### Method GET ### Endpoint /spotify/android-sdk/player/context ### Parameters None ### Request Example None ### Response #### Success Response (200) - **uri** (string) - The URI of the current context. - **title** (string) - The title of the current context. - **subtitle** (string) - The subtitle of the current context. - **imageUrl** (string) - The image URL for the current context. #### Response Example ```json { "uri": "spotify:album:12345", "title": "Example Album", "subtitle": "Artist Name", "imageUrl": "https://example.com/image.jpg" } ``` ``` -------------------------------- ### Images API - Get Image Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Fetches an image from the Spotify app, with an option to specify the preferred size. ```APIDOC ## GET /spotify/android-sdk/images ### Description Fetches an image from the Spotify app. This endpoint has two variations: one that fetches a large image by default and another that allows specifying the image dimension. ### Method GET ### Endpoint /spotify/android-sdk/images ### Parameters #### Query Parameters - **imageUri** (ImageUri) - Required - The URI of the image to fetch. - **dimension** (Image.Dimension) - Optional - The preferred dimension for the image. If not provided, defaults to `Image.Dimension.LARGE`. ### Request Example ```json { "imageUri": "spotify:image:abcdef1234567890abcdef1234567890", "dimension": "LARGE" } ``` ### Response #### Success Response (200) - **imageBytes** (byte[]) - The image data as a byte array. #### Response Example ```json // Binary image data would be returned here ``` ``` -------------------------------- ### ListItem Class Documentation Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/protocol/types/ListItem.html Details about the ListItem class, its fields, constructor, and methods. ```APIDOC ## ListItem Class ### Description Represents a list item within the Spotify SDK, containing information such as title, subtitle, image, and playback status. ### Fields * **imageUri** (ImageUri) - The URI for the item's image. * **title** (String) - The title of the list item. * **subtitle** (String) - The subtitle of the list item. * **playable** (boolean) - Indicates if the item is playable. * **hasChildren** (boolean) - Indicates if the item has child elements. ### Constructor Detail * #### ListItem public ListItem(String id, String uri, ImageUri imageUri, String title, String subtitle, boolean playable, boolean hasChildren) Constructs a new ListItem with the provided details. ### Method Detail * #### equals public boolean equals(Object o) Overrides: `equals` in class `Object` Compares this ListItem to another object for equality. * #### hashCode public int hashCode() Overrides: `hashCode` in class `Object` Returns the hash code value for this ListItem. * #### toString public String toString() Overrides: `toString` in class `Object` Returns a string representation of the ListItem. ``` -------------------------------- ### Info Class Constructor Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/protocol/types/Info.html Details the constructor for the Info class, which accepts parameters for all its fields, including protocol version, required features, and various identification and dimension attributes. ```java public Info(int protocolVersion, java.util.List requiredFeatures, java.lang.String id, java.lang.String name, java.lang.String model, java.lang.String category, java.lang.String version, java.lang.String imageType, int defaultImageWidth, int defaultImageHeight, int defaultThumbnailImageWidth, int defaultThumbnailImageHeight) ``` -------------------------------- ### Implementing Classes Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/com/spotify/sdk/android/auth/AuthorizationHandler.html Lists the known classes that implement the AuthorizationHandler interface. ```APIDOC ## Implementing Classes * `com.spotify.sdk.android.auth.browser.BrowserAuthHandler` * `com.spotify.sdk.android.auth.app.SpotifyAuthHandler` ``` -------------------------------- ### Player API - Get Crossfade State Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Retrieves the current state of the audio crossfade setting in the Spotify app. ```APIDOC ## GET /spotify/android-sdk/player/crossfade ### Description Retrieves the current state of the audio crossfade setting. ### Method GET ### Endpoint /spotify/android-sdk/player/crossfade ### Parameters #### Query Parameters - **None** ### Request Example ```json {} ``` ### Response #### Success Response (200) - **crossfadeState** (object) - The state of the crossfade setting. #### Response Example ```json { "crossfadeState": { "duration": 5 } } ``` ``` -------------------------------- ### General Utility Methods Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html General utility methods for the Spotify Android SDK. ```APIDOC ## General Utility Methods ### setDebugMode #### Description Enables excessive logging for debugging purposes. ### Method `POST` (or relevant method based on SDK implementation) ### Endpoint `/spotify/android-sdk/utility/setDebugMode` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **enabled** (boolean) - Required - True to enable debug mode, false to disable. ### Request Example ```json { "enabled": true } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Authenticate with Spotify SDK (Java) Source: https://context7.com/spotify/android-sdk/llms.txt This Java code demonstrates how to use the Spotify Authentication Library for Android to request an access token or an authorization code. It includes setting up the authorization request with client ID, redirect URI, and desired scopes, then launching the login activity. The response handling shows how to retrieve the token or code and log potential errors. It also includes an example of calling the Spotify Web API using the obtained access token. ```java import com.spotify.sdk.android.auth.AuthorizationClient; import com.spotify.sdk.android.auth.AuthorizationRequest; import com.spotify.sdk.android.auth.AuthorizationResponse; import android.content.Intent; import android.util.Log; import androidx.appcompat.app.AppCompatActivity; import okhttp3.Call; import okhttp3.Callback; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import java.io.IOException; public class AuthenticationActivity extends AppCompatActivity { private static final String CLIENT_ID = "your_client_id_here"; private static final String REDIRECT_URI = "your-app://callback"; private static final int AUTH_TOKEN_REQUEST_CODE = 0x10; private static final int AUTH_CODE_REQUEST_CODE = 0x11; private String mAccessToken; public void requestAccessToken() { AuthorizationRequest request = new AuthorizationRequest.Builder( CLIENT_ID, AuthorizationResponse.Type.TOKEN, REDIRECT_URI ) .setScopes(new String[]{ "user-read-email", "user-read-private", "playlist-read-private", "app-remote-control" }) .setShowDialog(false) .build(); AuthorizationClient.openLoginActivity( this, AUTH_TOKEN_REQUEST_CODE, request ); } public void requestAuthorizationCode() { AuthorizationRequest request = new AuthorizationRequest.Builder( CLIENT_ID, AuthorizationResponse.Type.CODE, REDIRECT_URI ) .setScopes(new String[]{"user-read-email"}) .build(); AuthorizationClient.openLoginActivity( this, AUTH_CODE_REQUEST_CODE, request ); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); AuthorizationResponse response = AuthorizationClient.getResponse( resultCode, data ); if (response.getError() != null && !response.getError().isEmpty()) { Log.e("Auth", "Authentication error: " + response.getError()); return; } if (requestCode == AUTH_TOKEN_REQUEST_CODE) { mAccessToken = response.getAccessToken(); Log.d("Auth", "Access token obtained: " + mAccessToken); // Use token to call Spotify Web API callSpotifyWebApi(mAccessToken); } else if (requestCode == AUTH_CODE_REQUEST_CODE) { String authCode = response.getCode(); Log.d("Auth", "Authorization code obtained: " + authCode); // Exchange code for token on backend server } } private void callSpotifyWebApi(String accessToken) { OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("https://api.spotify.com/v1/me") .addHeader("Authorization", "Bearer " + accessToken) .build(); client.newCall(request).enqueue(new Callback() { @Override public void onResponse(Call call, Response response) throws IOException { String jsonData = response.body().string(); Log.d("WebAPI", "User profile: " + jsonData); } @Override public void onFailure(Call call, IOException e) { Log.e("WebAPI", "Request failed: " + e.getMessage()); } }); } } ``` -------------------------------- ### PlayerState - Get Player State Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Retrieves the current state of the Spotify player, including playback position, restrictions, and speed. ```APIDOC ## GET /spotify/android-sdk/player/state ### Description Retrieves the current state of the Spotify player, including playback position, restrictions, and speed. ### Method GET ### Endpoint /spotify/android-sdk/player/state ### Parameters None ### Request Example None ### Response #### Success Response (200) - **playbackPosition** (long) - Playback position in milliseconds. - **playbackRestrictions** (PlayerRestrictions) - Player restrictions for the current state. - **playbackSpeed** (int) - Playback speed relative to wall time. #### Response Example ```json { "playbackPosition": 120000, "playbackRestrictions": { "canSkipNext": true, "canSkipPrevious": true, "canSeek": true }, "playbackSpeed": 1 } ``` ``` -------------------------------- ### SpotifyNativeAuthUtil - Auth Activity Intent Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs/index-all.html Utility for creating intents to launch the Spotify authentication flow within the installed Spotify application. ```APIDOC ## SpotifyNativeAuthUtil ### Description Provides utility methods for native Spotify authentication. ### Static Method - **createAuthActivityIntent(Context)**: Creates an intent that will launch the auth flow on the currently installed Spotify application. ``` -------------------------------- ### LoginActivity and Authorization Request Source: https://github.com/spotify/android-sdk/blob/master/auth-lib/docs-store/index-all.html Details methods for initiating the login flow and retrieving details from an AuthorizationRequest. ```APIDOC ## Login Activity and Authorization Request Utilities ### Description This section describes methods related to initiating the Spotify authorization flow using `LoginActivity` and retrieving various details from an `AuthorizationRequest` object. ### Class: LoginActivity #### Static Method - **getAuthIntent(Activity activity, AuthorizationRequest request)**: Creates and returns an `Intent` that can be used to start the Spotify login activity. This method requires the current `Activity` and an `AuthorizationRequest` object specifying the authorization parameters. ### Class: AuthorizationRequest #### Instance Methods - **getCampaign()**: Retrieves the campaign information associated with this authorization request. - **getClientId()**: Returns the client ID for the Spotify application making the request. - **getCustomParam(String key)**: Retrieves the value of a custom parameter specified in the authorization request. - **getRedirectUri()**: Returns the redirect URI configured for this authorization request. ### Usage Example (Starting Auth Flow) ```java AuthorizationRequest request = AuthorizationRequest.builder() .setClientId("your_client_id") .setRedirectUri("your_redirect_uri") .setScopes(new String[]{"user-read-private", "playlist-read-private"}) .build(); Intent authIntent = LoginActivity.getAuthIntent(this, request); startActivityForResult(authIntent, AUTH_REQUEST_CODE); ``` ### Usage Example (Getting Request Details) ```java // Assuming 'request' is an AuthorizationRequest object String clientId = request.getClientId(); Uri redirectUri = request.getRedirectUri(); String campaign = request.getCampaign(); ``` ``` -------------------------------- ### Get All Auth Methods (Java) Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/com/spotify/android/appremote/api/ConnectionParams.AuthMethod.html Retrieves an array of all available ConnectionParams.AuthMethod constants. This method is useful for iterating through all possible authentication strategies. ```java public static ConnectionParams.AuthMethod[] values() // Example usage: for (ConnectionParams.AuthMethod c : ConnectionParams.AuthMethod.values()) System.out.println(c); ``` -------------------------------- ### Subscription Lifecycle Callback Source: https://github.com/spotify/android-sdk/blob/master/app-remote-lib/docs/index-all.html Manages the lifecycle events of a subscription. It provides methods for `onStart` and `onStop`. ```APIDOC ## Subscription.LifecycleCallback ### Description Interface for handling the lifecycle events of a subscription. ### Methods #### onStart() - **Description**: Called when the Subscription starts. #### onStop() - **Description**: Called when the Subscription stops. ### Example ```java // To implement: // void onStart(); // void onStop(); ``` ```