media player - Stop sound file when back pressed in Android -


i have audio files in listview play them randomly. while file playing want go pressing button, in method onbackpressed put following

 if(mmediaplayer.isplaying())     {         mmediaplayer.release();         mmediaplayer = null;     }else     {         //show message or     } 

but not working , fatal exception main nullpointerexception in case audio not playing

try code , may you

 if(mmediaplayer!=null && mmediaplayer.isplaying())     {         mmediaplayer.release();         mmediaplayer = null;     }else     {         //show message or     } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -