[Android] VideoPlayerActivity: avoid NullPointerException

Edward Wang git at videolan.org
Wed Jun 11 23:00:03 CEST 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Wed Jun 11 16:59:26 2014 -0400| [78abfbf2c2b9b8939c3be972e9cb37c2e314c603] | committer: Edward Wang

VideoPlayerActivity: avoid NullPointerException

Don't use mAudioManager before it is initialized

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=78abfbf2c2b9b8939c3be972e9cb37c2e314c603
---

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java   |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 00f117d..84c2b95 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -254,9 +254,12 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
             Log.d(TAG, "MediaRouter information : " + mMediaRouter  .toString());
         }
 
-
         mSettings = PreferenceManager.getDefaultSharedPreferences(this);
 
+        /* Services and miscellaneous */
+        mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
+        mAudioMax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
+
         mEnableCloneMode = mSettings.getBoolean("enable_clone_mode", false);
         createPresentation();
         setContentView(mPresentation == null ? R.layout.player : R.layout.player_remote_control);
@@ -349,10 +352,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         mLoadingText = (TextView) findViewById(R.id.player_overlay_loading_text);
         startLoadingAnimation();
 
-        /* Services and miscellaneous */
-        mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
-        mAudioMax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
-
         mSwitchingView = false;
         mEndReached = false;
 



More information about the Android mailing list