button sound and reset button not functioning Android java
<p>I am creating a simple Click Counter Android App using Java. I am new to Java. Here is my code below, the gui has different buttons with different functions, for example the count button itself, a reset count button, and a mute sound button.</p>

<pre><code>public class wazeefa extends Activity { 

//Count Button 
TextView txtCount; 
ImageView image; 
Button btnCount; 
Button wmute; 
Button wreset; 
public static int count=0; 
SharedPreferences app_preferences; 
MediaPlayer mpButtonClick; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
// The activity is being created. 
setContentView(R.layout.wazeefa); 

//SAVE COUNT 
app_preferences = this.getSharedPreferences("myPrefscount", MODE_WORLD_READABLE); 


count = app_preferences.getInt("count", 0); 

txtCount = (TextView)findViewById(R.id.wcount); 
txtCount.setText("This app has been started " + count + " times."); 


txtCount = (TextView)findViewById(R.id.wcount); 
txtCount.setText("This app has been started " + count + " times."); 

//Button SOUND AND COUNT 
mpButtonClick = MediaPlayer.create(this, R.raw.bubble); 
//RESET Button 
wreset = (Button)findViewById(R.id.wreset); 

txtCount = (TextView)findViewById(R.id.wcount); 
txtCount.setText(String.valueOf(count)); 

btnCount = (Button)findViewById(R.id.wclick); 
btnCount.setOnClickListener(new View.OnClickListener() { 
public void onClick(View v) { 
image = (ImageView) findViewById(R.id.imageview); 
count++; 
if (count &gt; 50) count = 0; image.setImageResource(R.drawable.duroodimage); 
if (count &gt; 0) image.setImageResource(R.drawable.duroodimage); 
if (count &gt; 9) image.setImageResource(R.drawable.zikrimage); 
if (count &gt; 39) image.setImageResource(R.drawable.duroodimage); 
txtCount.setText(String.valueOf(count)); 
} 
}); 

wreset.setOnClickListener(new View.OnClickListener() { 
public void onClick(View v) { 
count = 0; 
image.setImageResource(R.drawable.duroodimage);; 
txtCount.setText("0"); 
} 
}); 
} 

@Override 
protected void onPause() { 
super.onPause(); 
// save count value here 

SharedPreferences.Editor editor = app_preferences.edit(); 
editor.putInt("count", count); 
editor.commit(); 
}

//MUTE button
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.wmute:
AudioManager.setMode(AudioManager.MODE_IN_CALL);
AudioManager.setStreamSolo(AudioManager.STREAM_VOICE_CALL, true);
default:
AudioManager.setMode(AudioManager.MODE_NORMAL );
AudioManager.setStreamSolo(AudioManager.STREAM_VOICE_CALL, false);
break;
}

}
</code></pre>

<p>I have 1 issue:</p>

<p>When I go back into the app and the count shows as '5' just for example, the Reset button no longer functions - it does nothing, I get an error message on AVD saying 'unfortunately 'App' has stopped'. But when I continue the count and then hit the Reset button it works changes the count to zero again</p>

<p>Any suggestions on the above issue, have I missed anything or placed code in the wrong areas?  The button sound was working before I edited the code, to save the 'count' data.
Let me know if I'm being vague...</p>

<p>The Crash Log:</p>

<pre><code>12-24 18:07:42.661: W/Trace(3633): Unexpected value from nativeGetEnabledTags: 0
12-24 18:07:42.741: D/AndroidRuntime(3633): Shutting down VM
12-24 18:07:42.741: W/dalvikvm(3633): threadid=1: thread exiting with uncaught     exception (group=0x40a70930)
12-24 18:07:42.811: E/AndroidRuntime(3633): FATAL EXCEPTION: main
12-24 18:07:42.811: E/AndroidRuntime(3633): java.lang.NullPointerException
12-24 18:07:42.811: E/AndroidRuntime(3633):     at  com.shaadcorp.wazaifapp.wazeefa$2.onClick(wazeefa.java:81)
12-24 18:07:42.811: E/AndroidRuntime(3633):     at android.view.View.performClick(View.java:4202)
12-24 18:07:42.811: E/AndroidRuntime(3633):     at android.view.View$PerformClick.run(View.java:17340)
12-24 18:07:42.811: E/AndroidRuntime(3633):     at android.os.Handler.handleCallback(Handler.java:725)
12-24 18:07:42.811: E/AndroidRuntime(3633):     at  android.os.Handler.dispatchMessage(Handler.java:92)
12-24 18:07:42.811: E/AndroidRuntime(3633):     at android.os.Looper.loop(Looper.java:137)
12-24 18:07:42.811: E/AndroidRuntime(3633):     at android.app.ActivityThread.main(ActivityThread.java:5039)
12-24 18:07:42.811: E/AndroidRuntime(3633):     at java.lang.reflect.Method.invokeNative(Native Method)
12-24 18:07:42.811: E/AndroidRuntime(3633):     at java.lang.reflect.Method.invoke(Method.java:511)
12-24 18:07:42.811: E/AndroidRuntime(3633):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-24 18:07:42.811: E/AndroidRuntime(3633):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-24 18:07:42.811: E/AndroidRuntime(3633):     at dalvik.system.NativeStart.main(Native     Method)
12-24 18:07:48.842: I/Process(3633): Sending signal. PID: 3633 SIG: 9
12-24 18:07:51.572: E/Trace(3808): error opening trace file: No such file or directory     (2)
</code></pre>
