When the application was minimized (for example, when the home button was pressed), the message "An error occurred in the application" narrator "." How to fix?

Here is the code

package com.example.narrator; import com.actionbarsherlock.view.MenuItem; import com.slidingmenu.lib.SlidingMenu; import com.slidingmenu.lib.app.SlidingFragmentActivity; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.view.WindowManager; import android.widget.MediaController; import android.widget.VideoView; public class MainActivity extends SlidingFragmentActivity { private Fragment mContent; VideoView vv; SlidingMenu sm; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.app_name); setContentView(R.layout.activity_main); vv = (VideoView) findViewById(R.id.videoView1); vv.setMediaController(new MediaController(vv.getContext())); vv.requestFocus(); setBehindContentView(R.layout.menu_frame); getSlidingMenu().setSlidingEnabled(true); getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportFragmentManager() .beginTransaction() .replace(R.id.menu_frame, new time()) .commit(); sm = getSlidingMenu(); sm.setBehindOffsetRes(R.dimen.slidingmenu_offset); sm.setShadowWidthRes(R.dimen.shadow_width); sm.setShadowDrawable(R.drawable.shadow); sm.setBehindScrollScale(0f); sm.setFadeDegree(0.25f); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: toggle(); } return super.onOptionsItemSelected(item); } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); getSupportFragmentManager().putFragment(outState, "mContent", mContent); } public void switchContent(String path) { vv.setVideoURI(Uri.parse(path)); toggle(); } } 
  • Show code. Perhaps there is a problem with your onPause . Or for example in onSaveInstance . - KoVadim
  • Log in the studio! It is obvious that an error in one of the 3 methods: onPause() , onStop() or onDestroy() - it remains only to understand which one. - Barmaley

1 answer 1

mContent = null, therefore the error ... replace with getContext ()