本文整理汇总了Java中com.spotify.sdk.android.authentication.AuthenticationResponse.getType方法的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationResponse.getType方法的具体用法?Java AuthenticationResponse.getType怎么用?Java AuthenticationResponse.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.spotify.sdk.android.authentication.AuthenticationResponse
的用法示例。
在下文中一共展示了AuthenticationResponse.getType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}
}
}
示例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: 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;
}
}