8
我目前正在执行Spotify API的Android应用程序。我有所有的代码连接我的应用程序使用教程,并一直在我的应用程序现在有一段时间了。在验证用户身份后,通过我的应用播放歌曲时,它完美地工作,即在我的模拟器上。当我将它切换到我的手机时,它不起作用,并在android响应中给了我一个INVALID_APP_ID错误。当我将手机中的Spotify卸载并尝试通过我的应用程序进行登录时,我可以在手机上播放音乐,而不会发生任何崩溃。所以我的问题是如何解决这个问题?这里是我的验证用户代码:Spotify API:INVALID_APP_ID
@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 == requestcode) {
AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent);
if (response.getType() == AuthenticationResponse.Type.TOKEN) {
Config playerConfig = new Config(this, response.getAccessToken(), client_id);
token = response.getAccessToken();
Spotify.getPlayer(playerConfig, this, new Player.InitializationObserver() {
@Override
public void onInitialized(Player player) {
mPlayer = player;
mPlayer.addConnectionStateCallback(.this);
mPlayer.addPlayerNotificationCallback(.this);
}
@Override
public void onError(Throwable throwable) {
Log.e("MainActivity", "Could not initialize player: " + throwable.getMessage());
}
});
}
}
}
这正是发生在我身上的事情。我会尝试遵循thye说明并发布我的结果 – chntgomez