Permalink
Browse files

Fixed fetching the playing track ID on old Android versions that use …

…ints for the IDs.
  • Loading branch information...
jjc1138
jjc1138 committed Mar 6, 2011
1 parent 3aef51d commit b90174f3824e4b822a479589359585aef0ecb5c8
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/net/jjc1138/android/scrobbler/ScrobblerService.java
@@ -64,6 +64,17 @@
class Track implements Serializable {
private static final String sources = "PREU";
public static long getID(Intent i) {
// It might be in a long extra or an int extra, so we have to check
// both:
final int def = -1;
long id = i.getLongExtra("id", def);
if (id != def) {
return id;
}
return i.getIntExtra("id", def);
}
public Track(Intent i, Context c) throws InvalidMetadataException {
String iSource = i.getStringExtra("source");
if (iSource == null || iSource.length() < 1) {
@@ -75,7 +86,7 @@ public Track(Intent i, Context c) throws InvalidMetadataException {
}
}
id = i.getLongExtra("id", -1);
id = getID(i);
if (id != -1) {
final String[] columns = new String[] {
@@ -653,7 +664,7 @@ private void enqueue(QueueEntry entry) {
private void handleIntent(Intent intent) {
Log.v(LOG_TAG, "Status: " +
((intent.getBooleanExtra("playing", false) ? "playing" : "stopped")
+ " track " + intent.getLongExtra("id", -1)));
+ " track " + Track.getID(intent)));
if (!prefs.getBoolean("enable", true)) {
return;

0 comments on commit b90174f

Please sign in to comment.