jkovacs / lastfm-java

Java bindings for the Last.fm Web Services
BSD 2-Clause "Simplified" License
73 stars 34 forks source link

Can't create request on Android #3

Open suicvne opened 8 years ago

suicvne commented 8 years ago

For whatever reason, I'm unable to make any requests on Android. Logcat only shows that the request is being opened, but nothing else.

Upon importing the source into Android studio, I can trace it back as far as into the openPostConnection method. The part where the urlConnection's OutputStream is passed into the outputStream variable is never called, and stops after "urlConnection.setDoOutput(true);". However, if I set a System.out after urlConnection.setDoOutput(true), this is called. It just breaks off entirely after that, no exceptions seem to be thrown, and any of my code after my initial "User.getWeeklyAlbumChart" is not executed, completely broken off. I am unsure what is happening.

I came across this Stackoverflow question: http://stackoverflow.com/questions/8438415/last-fm-api-call-from-android-application And tried setting cache to null as the answer suggested, but this had no effect on anything.

My code is simplistic enough code that doesn't require authentication of the user, just getting their top tracks for the week (Android port of my lastfm-collage-generator repository). Internet permission is declared in the manifest and my device is online.

Any idea as to what on earth could be going on? Any possible solutions?

Thanks

jkovacs commented 8 years ago

Can you push your android port to github so I can take a look to troubleshoot this?

In any case, can you make sure this is not caused by the recent Last.fm site update (see here), e.g. by trying if some other API methods work or not?

Riddim commented 8 years ago

When I try to User.getWeeklyArtistChart(user, 10, key); on android this happens:

Caused by: de.umass.lastfm.CallException: Caching/Reloading failed
at de.umass.lastfm.Caller.call(Caller.java:246)
at de.umass.lastfm.Caller.call(Caller.java:189)
at de.umass.lastfm.Chart.getChart(Chart.java:103)
at de.umass.lastfm.Chart.getChart(Chart.java:80)
at de.umass.lastfm.User.getWeeklyArtistChart(User.java:244)
at de.umass.lastfm.User.getWeeklyArtistChart(User.java:240)
nrmnrm commented 7 years ago

Original issue is not an issue with this library. Problem is that Android does not allow network operations on UI thread. You have to move calls to the library into an asynctask.