本文整理汇总了Java中com.spotify.sdk.android.authentication.AuthenticationResponse.getAccessToken方法的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationResponse.getAccessToken方法的具体用法?Java AuthenticationResponse.getAccessToken怎么用?Java AuthenticationResponse.getAccessToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.spotify.sdk.android.authentication.AuthenticationResponse
的用法示例。
在下文中一共展示了AuthenticationResponse.getAccessToken方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
});
}
}
示例3: 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;
}
}
}
示例4: 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();
}
}
示例5: onNewIntent
import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入方法依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Uri uri = intent.getData();
Log.i(TAG, "New intent!" + uri);
if (uri != null) {
AuthenticationResponse response = SpotifyAuthentication.parseOauthResponse(uri);
String accessToken = response.getAccessToken();
Log.i(TAG, "Authentication successful!");
this.accessToken = accessToken;
}else{
Log.i(TAG, "Authentication failed!");
}
}