public class SpotifyApi
extends java.lang.Object
Application.
After the initialization, you can access the singleton instance via getInstance().
Basic Usage:
- If you need to authorize user, use authorize(android.content.Context, String[]).
- If you are to access Web API, use getApiService(). Service object is generated by Retrofit.| Modifier and Type | Class and Description |
|---|---|
static interface |
SpotifyApi.AuthenticationListener |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
TAG |
| Modifier and Type | Method and Description |
|---|---|
void |
authorize(android.content.Context context,
java.lang.String[] scopes)
Start user's authorization.
|
void |
authorize(android.content.Context context,
java.lang.String[] scopes,
boolean showDialog)
Start user's authorization.
|
void |
blockingRefreshTokenIfNeeded()
Refresh access token in the same thread.
|
static void |
destroy()
Terminate singleton instance lifetime.
|
SpotifyService |
getApiService() |
SpotifyAuthenticateService |
getAuthService() |
ClientConfig |
getConfig() |
static SpotifyApi |
getInstance() |
AccessTokenStore |
getTokenStore() |
static void |
initialize(android.app.Application application,
ClientConfig config)
Initialize the singleton instance of this class.
|
boolean |
isAuthrorized() |
void |
onCallback(android.net.Uri data,
SpotifyApi.AuthenticationListener listener)
Call this method if user back to the activity which can handle the callback.
|
void |
refreshTokenIfNeeded(SpotifyApi.AuthenticationListener listener)
Refresh access token in the background thread.
|
public static void initialize(@NonNull
android.app.Application application,
@NonNull
ClientConfig config)
application - the application.config - your Spotify API configuration.public static SpotifyApi getInstance()
public static void destroy()
public SpotifyService getApiService()
public SpotifyAuthenticateService getAuthService()
public boolean isAuthrorized()
public void authorize(android.content.Context context,
java.lang.String[] scopes)
context - the context.scopes - the scopes you need.public void authorize(android.content.Context context,
java.lang.String[] scopes,
boolean showDialog)
context - the context, should be Activity context.scopes - the scopes you need.showDialog - set true if you always need to show prompt.public void onCallback(android.net.Uri data,
SpotifyApi.AuthenticationListener listener)
Activity.onNewIntent(android.content.Intent),
so keep in mind that your callback activity should be singleton in the back stack.data - the data in the Intent passed to your callback Activitylistener - callback listener that is invoked when the access token is retrievedpublic void refreshTokenIfNeeded(SpotifyApi.AuthenticationListener listener)
public void blockingRefreshTokenIfNeeded()
public ClientConfig getConfig()
public AccessTokenStore getTokenStore()