本文整理汇总了Java中com.spotify.sdk.android.authentication.AuthenticationResponse类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationResponse类的具体用法?Java AuthenticationResponse怎么用?Java AuthenticationResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticationResponse类属于com.spotify.sdk.android.authentication包,在下文中一共展示了AuthenticationResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAuthenticationComplete
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
private void onAuthenticationComplete(AuthenticationResponse authResponse, String clientID) {
Log.d("DEBUG", "Got authentication token");
if (mPlayer == null) {
Config playerConfig = new Config(this, authResponse.getAccessToken(), clientID);
mPlayer = Spotify.getPlayer(playerConfig, this, new SpotifyPlayer.InitializationObserver() {
@Override
public void onInitialized(SpotifyPlayer player) {
Log.d("DEBUG", "-- Player initialized --");
mPlayer
.setConnectivityStatus(mOperationCallback, getNetworkConnectivity(MainActivity.this));
mPlayer.addNotificationCallback(MainActivity.this);
mPlayer.addConnectionStateCallback(MainActivity.this);
}
@Override
public void onError(Throwable error) {
Log.d("DEBUG", "Error in initialization: " + error.getMessage());
}
});
} else {
mPlayer.login(authResponse.getAccessToken());
}
}
示例2: processRequestToken
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
String processRequestToken(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE) {
final AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, data);
SpotifyConfigFragment.setAccessToken(response.getAccessToken());
switch (response.getType()) {
case TOKEN:
Log.d("DEBUG", "Spotify Token: " + response.getAccessToken());
onAuthenticationComplete(response, getString(R.string.spotify_client_id));
SpotifyConfigFragment.setIsLoggedIn(true);
break;
case ERROR:
Log.d("DEBUG", "Spotify Error: " + response.getError());
break;
default:
Log.d("DEBUG", "Spotify Other: " + response.getState());
break;
}
}
return SpotifyConfigFragment.getAccessToken();
}
示例3: initializePlayer
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
private void initializePlayer() {
SharedPreferences prefsAppData = getSharedPreferences(getString(R.string.sharedpreferences_global), Context.MODE_PRIVATE);
if (prefsAppData.getInt(getString(R.string.responseType), -1) == AuthenticationResponse.Type.TOKEN.ordinal()) {
Config config = new Config(
this,
prefsAppData.getString(getString(R.string.spotifyAccessToken_value), null),
prefsAppData.getString(getString(R.string.clientId), null)
);
spotifyPlayer = Spotify.getPlayer(config, this, new Player.InitializationObserver() {
@Override
public void onInitialized(Player player) {
player.addConnectionStateCallback(MainActivity.connectionStateCallback);
player.addPlayerNotificationCallback(TracksActivity.this);
}
@Override
public void onError(Throwable throwable) {
Log.e("PLAYER", "ERROR: " + throwable.getMessage());
}
});
}
}
示例4: onCreate
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_authentication);
((Injector) getApplication()).inject(this);
overridePendingTransition(R.anim.short_fade_in, R.anim.short_fade_out);
AuthenticationRequest authRequest = new AuthenticationRequest.Builder(
BuildConfig.SPOTIFY_CLIENT_ID,
AuthenticationResponse.Type.TOKEN,
SpotifyConstants.REDIRECT_URI)
.setScopes(SpotifyConstants.DEFAULT_USER_SCOPES)
.build();
AuthenticationClient.openLoginActivity(this,
ApplicationConstants.LOGIN_INTENT_REQUEST_CODE,
authRequest);
}
示例5: onActivityResult
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
// Check if result comes from the correct activity
if (requestCode == REQUEST_CODE) {
AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent);
if (response.getType() == AuthenticationResponse.Type.TOKEN) {
// TODO progress dialog
SpotifyTvApplication.getInstance().startSpotifySession(MainActivity.this, response.getAccessToken(), new Runnable() {
@Override
public void run() {
init();
}
}, new Runnable() {
@Override
public void run() {
showError();
}
});
} else {
showError();
}
}
}
示例6: onNewIntent
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Uri uri = intent.getData();
if (uri != null) {
AuthenticationResponse response = SpotifyAuthentication.parseOauthResponse(uri);
Spotify spotify = new Spotify(response.getAccessToken());
mPlayer = spotify.getPlayer(this, "BeatMap", this, new Player.InitializationObserver()
{
@Override
public void onInitialized() {
mPlayer.addConnectionStateCallback(LoginActivity.this);
mPlayer.addPlayerNotificationCallback(LoginActivity.this);
}
@Override
public void onError(Throwable throwable) {
Log.e("LoginActivity", "Could not initialize player: " + throwable.getMessage());
}
});
}
}
示例7: onActivityResult
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// If logged into Spotify, retrieve an access code to make requests
if (requestCode == LOGIN_REQUEST_CODE) {
AuthenticationResponse response = AuthenticationClient
.getResponse(LOGIN_REQUEST_CODE, data);
switch (response.getType()){
// If received token
case TOKEN:
SpotifyManager.ACCESS_TOKEN = response.getAccessToken();
Log.wtf(TAG, "Got access token");
mSongDataFragment.notifySongDataAdapter();
break;
case ERROR:
SpotifyManager.ACCESS_TOKEN = SpotifyManager.NULL_ACCESS_TOKEN;
Log.wtf(TAG, "ERROR retrieving access token");
break;
case EMPTY:
SpotifyManager.ACCESS_TOKEN = SpotifyManager.NULL_ACCESS_TOKEN;
Log.wtf(TAG, "EMPTY access token");
break;
default:
SpotifyManager.ACCESS_TOKEN = SpotifyManager.NULL_ACCESS_TOKEN;
Log.wtf(TAG, "Could not retrieve access token");
break;
}
}
}
示例8: authenticateSpotify
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
/**
* Used to get access token to make any calls to the Spotify Api
* @param callingActivity
*/
public static void authenticateSpotify (Activity callingActivity){
AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(
callingActivity.getResources().getString(R.string.spotify_client_id),
AuthenticationResponse.Type.TOKEN,
callingActivity.getResources().getString(R.string.spotify_redirect_uri)
);
// builder.setScopes(new String[]{"streaming"});
AuthenticationRequest request = builder.build();
AuthenticationClient.openLoginActivity(
callingActivity,
LOGIN_REQUEST_CODE,
request
);
}
示例9: onCreate
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
AuthenticationRequest.Builder builder =
new AuthenticationRequest.Builder(
CLIENT_ID,
AuthenticationResponse.Type.TOKEN,
REDIRECT_URI);
builder.setScopes(SpotifyAuthorizationScopes.FULL_ACCESS_SCOPES);
AuthenticationRequest request = builder.build();
Log.e("STARTUP", "SPOTIFY TOKEN: " + Utils.getStringFromSharedPreferences(this, R.string.sharedpreferences_global, getString(R.string.spotifyAccessToken_value)));
Log.e("STARTUP", "SPOTIFY EXPIRY: " + Utils.getSharedPreferences(this, R.string.sharedpreferences_global).getInt(getString(R.string.spotifyAccessToken_expiration), -1));
Snackbar.make(
getWindow().getDecorView().getRootView(),
Utils.checkInternetConnectionString(this),
Snackbar.LENGTH_LONG
).show();
connectionStateCallback = this;
AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request);
buildRecycler();
}
示例10: getAuthenticationRequest
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
private AuthenticationRequest getAuthenticationRequest(AuthenticationResponse.Type type) {
return new AuthenticationRequest.Builder(CLIENT_ID, type, getRedirectUri().toString())
.setShowDialog(false)
.setScopes(new String[]{"user-read-email"})
.setCampaign("your-campaign-token")
.build();
}
示例11: onActivityResult
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
final AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, data);
if (AUTH_TOKEN_REQUEST_CODE == requestCode) {
mAccessToken = response.getAccessToken();
updateTokenView();
} else if (AUTH_CODE_REQUEST_CODE == requestCode) {
mAccessCode = response.getCode();
updateCodeView();
}
}
示例12: buildRequest
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
/***
* Build the REquest according to the configuration given
*
* @return
*/
private static AuthenticationRequest buildRequest(final Type type, final String apiCallback, final String[] scopes) {
AuthenticationResponse.Type spotifyType = (type == Type.CODE) ? AuthenticationResponse.Type.CODE : AuthenticationResponse.Type.TOKEN;
AuthenticationRequest.Builder builder = new AuthenticationRequest
.Builder(SpotifyManager.API_KEY, spotifyType, apiCallback).setScopes(scopes);
return builder.build();
}
示例13: onNewIntent
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
/***
* Called when used the method {@link #loginWithBrowser(Activity, Type, int, String[], OAuthListener)}
*
* @param intent
*/
public static void onNewIntent(Intent intent) {
Uri uri = intent.getData();
if (uri != null) {
AuthenticationResponse response = AuthenticationResponse.fromUri(uri);
handleResponse(response);
}
}
示例14: handleResponse
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
/***
* Manage the response of Spotify
*
* @param response
*/
private static void handleResponse(AuthenticationResponse response) {
switch (response.getType()) {
// Response was successful and contains auth token
case TOKEN:
SpotifyManager.oAuthListener.onReceived(response.getAccessToken());
break;
case CODE:
SpotifyManager.oAuthListener.onReceived(response.getCode());
break;
case ERROR:
SpotifyManager.oAuthListener.onError(response.getError());
break;
}
}
示例15: login
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
private void login(JSONArray scopes, Boolean fetchTokenManually) {
AuthenticationResponse.Type authType = fetchTokenManually ? AuthenticationResponse.Type.CODE :AuthenticationResponse.Type.TOKEN;
AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(clientId,
authType,
redirectUri);
builder.setScopes(new String[]{"user-read-private", "streaming"});
builder.setShowDialog(true);
AuthenticationRequest request = builder.build();
Log.d(TAG, "Client ID " + clientId + "AUTH RESPONSE TYPE " + AuthenticationResponse.Type.TOKEN + "REDIRECT URI " + redirectUri + " Scopes " + scopes + " manual " + fetchTokenManually);
AuthenticationClient.openLoginActivity(cordova.getActivity(), REQUEST_CODE, request);
}