Just follow this simple tutorial!
Make a layout and name it main.xml:
Note: provide your own crackimage and break glass audio.
Put the crackimage into drawable and then make a raw folder and put your breakglassaudio there..
main.xml
And then create an activity file and name it TapperAppActivity
TapperAppActivity.java
import java.util.Random; import com.example.tapperapp.R; import android.media.MediaPlayer; import android.os.Bundle; import android.os.Vibrator; import android.app.Activity; import android.content.Context; import android.util.TypedValue; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.view.WindowManager; import android.widget.Button; import android.widget.TextView; public class TapperAppActivity extends Activity implements OnClickListener{ MediaPlayer mPlayer; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Set application layout setContentView(R.layout.main); //Assign media player object with sound file // TextView dd = ((TextView)findViewById(R.id.blurb)); mPlayer = MediaPlayer.create(TapperAppActivity.this, R.raw.glass); //Find the button ((Button) findViewById(R.id.button)).setOnClickListener(this); } public void onClick(View v) { //If our applicaitons' b is clicked TextView dd = ((TextView)findViewById(R.id.blurb)); if (v.getId()==R.id.button) { //Get the button text int i = Integer.parseInt(((Button) v).getText().toString()); //Decrement button text value and set it as button text ((Button) v).setText(Integer.toString(--i)); //Create Random object Random gen = new Random(); //If random(0 - 9)+1 equals to 10 or i is lesser than 50 if ((gen.nextInt(10) + 1 == 10) || (i<50 data-blogger-escaped--1="" data-blogger-escaped-0="" data-blogger-escaped-0x6400ff00="" data-blogger-escaped-0x64cdc9c9="" data-blogger-escaped-0x64ffffff="" data-blogger-escaped-500="" data-blogger-escaped-ake="" data-blogger-escaped-all="" data-blogger-escaped-as="" data-blogger-escaped-audiblefx="" data-blogger-escaped-audio="" data-blogger-escaped-background="" data-blogger-escaped-blurb="" data-blogger-escaped-breaking="" data-blogger-escaped-button="" data-blogger-escaped-color="" data-blogger-escaped-crack="" data-blogger-escaped-dd.setvisibility="" data-blogger-escaped-drawable.cracked_screen="" data-blogger-escaped-effects="" data-blogger-escaped-et="" data-blogger-escaped-extview="" data-blogger-escaped-file="" data-blogger-escaped-findviewbyid="" data-blogger-escaped-for="" data-blogger-escaped-glass="" data-blogger-escaped-ibrate="" data-blogger-escaped-id.background="" data-blogger-escaped-id.blurb="" data-blogger-escaped-id.button="" data-blogger-escaped-id.title="" data-blogger-escaped-iew.invisible="" data-blogger-escaped-if="" data-blogger-escaped-image="" data-blogger-escaped-lay="" data-blogger-escaped-listener="" data-blogger-escaped-long="" data-blogger-escaped-mediaplayer="" data-blogger-escaped-method="" data-blogger-escaped-mplayer.release="" data-blogger-escaped-mplayer.start="" data-blogger-escaped-mplayer="null;" data-blogger-escaped-ms="" data-blogger-escaped-mv.vibrate="" data-blogger-escaped-mv="(Vibrator)getSystemService(Context.VIBRATOR_SERVICE);" data-blogger-escaped-new="" data-blogger-escaped-null="" data-blogger-escaped-object="" data-blogger-escaped-ondestroy="" data-blogger-escaped-pre="" data-blogger-escaped-private="" data-blogger-escaped-protected="" data-blogger-escaped-reate="" data-blogger-escaped-release="" data-blogger-escaped-setbackgroundcolor="" data-blogger-escaped-setbackgroundresource="" data-blogger-escaped-setonclicklistener="" data-blogger-escaped-settextcolor="" data-blogger-escaped-settextsize="" data-blogger-escaped-setvisibility="" data-blogger-escaped-sound="" data-blogger-escaped-super.ondestroy="" data-blogger-escaped-textview="" data-blogger-escaped-to="" data-blogger-escaped-touchfx="" data-blogger-escaped-utton="" data-blogger-escaped-v="" data-blogger-escaped-vibrate="" data-blogger-escaped-vibrator="" data-blogger-escaped-visual="" data-blogger-escaped-visualfx="" data-blogger-escaped-void="" data-blogger-escaped-with="" data-blogger-escaped-x6400ff00="" data-blogger-escaped-x64cdc9c9="" data-blogger-escaped-x64ffffff="" data-blogger-escaped-ypedvalue.complex_unit_sp="" title=""> Point to Note: In our activity we have use the random number picker, if you notice you see the number change and becoming lower and lower per onclick it is because we have set the random number picker in a range notice this code:if ((gen.nextInt(10) + 1 == 10) || (i<50 data-blogger-escaped-pre=""> In this code we have set the button and textview into invisible...dd.setVisibility(View.INVISIBLE); ((Button) v).setVisibility(View.INVISIBLE); ((Button) v).setTextSize(TypedValue.COMPLEX_UNIT_SP,14);Thats it! Have fun!