Last.fm API from Android App

I am trying to make a last.fm API request from an android application using this package: http://www.u-mass.de/lastfm

From a simple java command line program, it works, but not in an Android app. Using Windows and Eclipse

The code itself is very simple:

Artist artist = Artist.getInfo("Depeche Mode", "my_key"); 

I set internet permission in android manifest

  <uses-permission android:name="android.permission.INTERNET"></uses-permission> 

After the call, I end up here, where it prints "caching failed." http://code.google.com/p/lastfm-java/source/browse/trunk/src/de/umass/lastfm/Caller.java?spec=svn173&r=173

response code is -1

 int responseCode = urlConnection.getResponseCode(); 

Any ideas what I'm doing wrong?

+4
source share
1 answer

I had the same problem. His reported error.

The solution I found was as follows: Just add this line somewhere in your code, which will be run before calling any of the api: methods. Caller.getInstance () setCache (zero);

Note: this will disable caching.

for more information check this link

+3
source

Source: https://habr.com/ru/post/1385432/


All Articles