Make sure we actually have an adapter before trying to access it.
Fixes bug 2177763.
diff --git a/src/com/android/music/AlbumBrowserActivity.java b/src/com/android/music/AlbumBrowserActivity.java
index 49a3893..49d511c 100644
--- a/src/com/android/music/AlbumBrowserActivity.java
+++ b/src/com/android/music/AlbumBrowserActivity.java
@@ -147,7 +147,9 @@
     @Override
     public void onDestroy() {
         MusicUtils.unbindFromService(this);
-        if (!mAdapterSent) {
+        // if we have an adapter and didn't send it off to another activity yet, we should
+        // close the cursor
+        if (!mAdapterSent && mAdapter != null) {
             Cursor c = mAdapter.getCursor();
             if (c != null) {
                 c.close();
diff --git a/src/com/android/music/ArtistAlbumBrowserActivity.java b/src/com/android/music/ArtistAlbumBrowserActivity.java
index 9aa42b4..8fb452b 100644
--- a/src/com/android/music/ArtistAlbumBrowserActivity.java
+++ b/src/com/android/music/ArtistAlbumBrowserActivity.java
@@ -154,7 +154,9 @@
     @Override
     public void onDestroy() {
         MusicUtils.unbindFromService(this);
-        if (!mAdapterSent) {
+        // if we have an adapter and didn't send it off to another activity yet, we should
+        // close the cursor
+        if (!mAdapterSent && mAdapter != null) {
             Cursor c = mAdapter.getCursor();
             if (c != null) {
                 c.close();
diff --git a/src/com/android/music/PlaylistBrowserActivity.java b/src/com/android/music/PlaylistBrowserActivity.java
index ccdb529..3c5ad22 100644
--- a/src/com/android/music/PlaylistBrowserActivity.java
+++ b/src/com/android/music/PlaylistBrowserActivity.java
@@ -169,7 +169,9 @@
     @Override
     public void onDestroy() {
         MusicUtils.unbindFromService(this);
-        if (!mAdapterSent) {
+        // if we have an adapter and didn't send it off to another activity yet, we should
+        // close the cursor
+        if (!mAdapterSent && mAdapter != null) {
             Cursor c = mAdapter.getCursor();
             if (c != null) {
                 c.close();
diff --git a/src/com/android/music/TrackBrowserActivity.java b/src/com/android/music/TrackBrowserActivity.java
index 078b17c..f44c61b 100644
--- a/src/com/android/music/TrackBrowserActivity.java
+++ b/src/com/android/music/TrackBrowserActivity.java
@@ -233,9 +233,9 @@
             // we end up here in case we never registered the listeners
         }
         
-        // if we didn't send the adapter off to another activity, we should
+        // if we have an adapter and didn't send it off to another activity yet, we should
         // close the cursor
-        if (!mAdapterSent) {
+        if (!mAdapterSent && mAdapter != null) {
             Cursor c = mAdapter.getCursor();
             if (c != null) {
                 c.close();