我在应用程序项目中使用 andorid-java 包装器作为 spotify api。
https://github.com/kaaes/spotify-web-api-android
我很难从我的 Spotify API 请求中提取响应。提取单个响应很容易,但是一旦响应是分页对象,我就会挣扎。如何从 logcat 中的“getArtistAlbums”打印专辑标题,以检查响应是否正确?
这是解释我的问题的代码:
@TargetApi(Build.VERSION_CODES.O)
private void setupSpotifyAPI() {
Intent intent = getIntent();
token = intent.getStringExtra(EXTRA_TOKEN);
logMessage("Api Client created");
spotifyApi = new SpotifyApi();
spotifyApi.setAccessToken(token);
final SpotifyService spotify = spotifyApi.getService();
spotify.getArtistAlbums("0TnOYISbd1XYRBk9myaseg", new SpotifyCallback<Pager<Album>>() {
@Override
public void failure(SpotifyError spotifyError) {
}
@Override
public void success(Pager<Album> albumPager, Response response) {
Log.v("hello", albumPager.items.toString());
}
});
}
}
对于这个确切的工作,logcat 打印:
D/MAIN: Api Client created
08-15 12:48:57.218 20889-21973/applicationname.companydomain.myapplication D/Retrofit: ---> HTTP GET https://api.spotify.com/v1/artists/0TnOYISbd1XYRBk9myaseg/albums
08-15 12:48:57.244 20889-20931/applicationname.companydomain.myapplication D/EGL_emulation: eglMakeCurrent: 0xa3d040c0: ver 3 0 (tinfo 0xa3d032d0)
08-15 12:48:57.764 20889-20931/applicationname.companydomain.myapplication D/EGL_emulation: eglMakeCurrent: 0xa3d040c0: ver 3 0 (tinfo 0xa3d032d0)
08-15 12:48:58.173 20889-21973/applicationname.companydomain.myapplication D/Retrofit: <--- HTTP 200 https://api.spotify.com/v1/artists/0TnOYISbd1XYRBk9myaseg/albums (953ms)
08-15 12:48:58.225 20889-20889/applicationname.companydomain.myapplication V/hello: [kaaes.spotify.webapi.android.models.Album@833d3be, kaaes.spotify.webapi.android.models.Album@b893c1f, kaaes.spotify.webapi.android.models.Album@8ba3b6c
where kaaes.spotify.webapi.android.models.Album@833d3be 只是一个对象,而不是元数据。
使用时
response.getBody().toString()
logcat 打印:
V/hello: retrofit.client.UrlConnectionClient$TypedInputStream@77dfecd
我怎样才能继续获取我真正需要的数据,而不仅仅是对象?
相关分类