過去数日間、私は 1 つの問題に直面しています。Android デバイスに Spotify アプリケーションをインストールした後、アプリケーションで Spotify にログインします。
私のデバイスにSpotifyアプリケーションをインストールする前は、ログインとログアウトが適切に機能していましたが、Spotifyアプリケーションをインストールするとできません..
私はこれらを私のアンドロイドスタジオで使用しています。
compile 'com.spotify.sdk:spotify-auth:1.0.0-beta12@aar'
compile 'com.spotify.sdk:spotify-player:1.0.0-beta12@aar'
これらのコードでログイン:
AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(CLIENT_ID, AuthenticationResponse.Type.TOKEN, REDIRECT_URI);
builder.setScopes(new String[]{"user-read-private", "user-read-birthdate", "user-read-email", "streaming"});
AuthenticationRequest request = builder.build();
AuthenticationClient.openLoginActivity(activity, REQUEST_CODE, request);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
final AuthenticationResponse authResponse = AuthenticationClient.getResponse(resultCode, data);
switch (authResponse.getType()) {
// Response was successful and contains auth token
case TOKEN:
Log.d("AccessToken", "" + authResponse.getAccessToken());
Toast.makeText(activity, "Login successfully", Toast.LENGTH_SHORT).show();
onBackPressed();
break;
// Auth flow returned an error
case ERROR:
// Handle error response
Toast.makeText(activity, "ERROR..", Toast.LENGTH_SHORT).show();
break;
case EMPTY:
Toast.makeText(activity, "EMPTY..", Toast.LENGTH_SHORT).show();
break;
// Most likely auth flow was cancelled
default:
// Handle other cases
}
}