From: masensio Date: Fri, 14 Feb 2014 12:36:47 +0000 (+0100) Subject: OC-2976: (Fix bug) App crashes when sharing a mp3 and other things X-Git-Tag: oc-android-1.5.5~48^2^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/4bb987e7b76d117c98269ff9b356050159a877df?ds=inline OC-2976: (Fix bug) App crashes when sharing a mp3 and other things --- diff --git a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java index 336f6b9a..4c52280e 100644 --- a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java @@ -588,17 +588,19 @@ public class PreviewMediaFragment extends FileFragment implements @Override public void onServiceConnected(ComponentName component, IBinder service) { - if (component.equals(new ComponentName(getActivity(), MediaService.class))) { - Log_OC.d(TAG, "Media service connected"); - mMediaServiceBinder = (MediaServiceBinder) service; - if (mMediaServiceBinder != null) { - prepareMediaController(); - playAudio(); // do not wait for the touch of nobody to play audio - - Log_OC.d(TAG, "Successfully bound to MediaService, MediaController ready"); - - } else { - Log_OC.e(TAG, "Unexpected response from MediaService while binding"); + if (getActivity() != null) { + if (component.equals(new ComponentName(getActivity(), MediaService.class))) { + Log_OC.d(TAG, "Media service connected"); + mMediaServiceBinder = (MediaServiceBinder) service; + if (mMediaServiceBinder != null) { + prepareMediaController(); + playAudio(); // do not wait for the touch of nobody to play audio + + Log_OC.d(TAG, "Successfully bound to MediaService, MediaController ready"); + + } else { + Log_OC.e(TAG, "Unexpected response from MediaService while binding"); + } } } }