Home Basics » Write For Us Categories Downloads Contact Us Site Map Advanced Search s earch this s ite...
HOME APPLICATIONS ANDROID SCREEN CRACK PRANK
Connect with us
Android screen crack prank
POSTED BY ANDROI D GURU ON AUG 20, 2012 I N APPLI CATI ONS | 5 COMMENTS
Tw eet 3 2 Share 12 Like 12 Send Share
Readers
In this post, we are going to develop an application, its kinda
game which can be used to prank your friends. . Yes, you
want to fool your friends with a simple android application,
just go through the post to develop one for you . I would
like to name this application – ‘Screen crack prank’. Like US?
Application’s theme:
Let your friends play the game on your Android phone and Like 854 Send
see how the screen cracks and the screen goes black and
also vibrates. Your friends will believe they broke your phone.
You must have already seen such applications in Google play Search this site
but creating one such application is really fun!!
Powered by Google
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Powered by Google
Let us start creating the application:
Either you can proceed with the below listings, or you can directly download code.
Create new android project [File >> New >> Android New Visitor? Like what you
read? Then do subscribe to
Project] with project name TapperApp Follow us on G+
our blog
Click next and select target android device version [I
chose version 2.2]
Subscribe
Click next and enter package name –
‘com.prgguru.android’ More Interesting Tutorials
Click finish
Layout creation:
We will create a simple layout which has one textview to display instructions and one button who is
the hero of ‘Screen Crack Prank’ app.
Main.xml:
Replace the XML present in /res/layout with the below one:
1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 android:orientation="vertical"
6 android:id="@+id/background">
7
8 <TextView
9 android:layout_width="fill_parent"
10 android:layout_height="wrap_content"
11 android:text="Challenge for you!" Suggest a topic
12 android:textStyle="bold"
13 android:textColor="#0587d9"
14 android:textSize="20sp"
15 android:layout_margin="20dip"
16 android:gravity="center"
17 android:id="@+id/title"/>
18
19 <TextView
20 android:layout_width="fill_parent"
21 android:layout_height="wrap_content"
22 android:textColor="#000"
23 android:layout_margin="20dip"
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
23 android:layout_margin="20dip"
24 android:text="INSTRUCTIONS:\n\nTry to tap the button 100 times within 30 seconds.\n\nBest of Luck!"
25 android:id="@+id/blurb"/>
26
27 <Button
28 android:layout_width="wrap_content"
29
30
android:layout_height="wrap_content"
android:layout_margin="20dip"
Recent posts
31 android:padding="25dip"
32 android:text="100"
33 android:layout_gravity="center" Android Autocomplete Textview Example
34 android:id="@+id/button"/>
35 Android JSON Web Service Tutorial
36 </LinearLayout>
jQuery Examples
The application layout should look like:
Recent comments
Android Guru on Android Webservice example
Android Guru on How to call Java web service
in android
Android Guru on How to call Java web service
in android
Archives
September 2013 (2)
August 2013 (1)
July 2013 (1)
May 2013 (5)
April 2013 (7)
March 2013 (1)
October 2012 (1)
September 2012 (2)
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
We have to add few resources before we proceed with writing logic for the application. August 2012 (9)
Load cracked_screen.png (crack image) under /res/drawable-hdpi folder and glass.ogg (glass July 2012 (9)
breaking sound file) under /res/raw folder. If raw folder is not created, create one under /res folder. June 2012 (7)
Application logic:
TapperAppActivity.java:
Logic behind the application is given below:
Categories
Open TapperAppAcitivty class under com.prgguru.android package and add the below class. Each line
AJAX (1)
of code is commented to let you understand the code logic.
Android Developers (1)
1 package com.prgguru.android; Applications (1)
2
3 import java.util.Random; Basics (5)
4 import com.example.tapperapp.R;
5 import android.media.MediaPlayer; Broadcast receivers (1)
6 import android.os.Bundle;
7 import android.os.Vibrator; Call (1)
8 import android.app.Activity;
9 import android.content.Context; Camera (2)
10 import android.view.View;
11 import android.view.View.OnClickListener; Eclipse (2)
12 import android.widget.Button; Email (1)
13 import android.widget.TextView;
14 Intent (1)
15 public class TapperAppActivity extends Activity implements OnClickListener{
16 MediaPlayer mPlayer; jQuery (1)
17 @Override
18 public void onCreate(Bundle savedInstanceState) { JSON (1)
19 super.onCreate(savedInstanceState);
20 //Set application layout Layout (6)
21 setContentView(R.layout.main);
22 //Assign media player object with sound file Localization (2)
23 mPlayer = MediaPlayer.create(TapperAppActivity.this, R.raw.glass);
Media (3)
24 //Find the button
25 ((Button) findViewById(R.id.button)).setOnClickListener(this); Music (3)
26 }
27 Mobile Web Framework (1)
28 public void onClick(View v) {
29 //If our applicaitons' button is clicked jQuery Mobile (1)
30 if (v.getId()==R.id.button) {
31 //Get the button text which is 100 Network (2)
32 int i = Integer.parseInt(((Button) v).getText().toString());
Notifications (1)
33 //Decrement button text value and set it as button text
34 ((Button) v).setText(Integer.toString(--i)); System Settings (1)
35 //Create Random object
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
35 //Create Random object
36 Random gen = new Random(); Text to Speech (1)
37 //If random value btwn (0 - 9)+1 equals to 10 or i is lesser than 50
38 if ((gen.nextInt(10) + 1 == 10) || (i<50)) { Toast (1)
39 //Call crack method
40 crack(); Vibrate service (1)
41 //Make listener to button as null
42 ((Button) v).setOnClickListener(null); Web Service (4)
43 }
44 } widget (4)
45 }
Button (2)
46
47 private void crack() { seekbar (1)
48 //Call audio effects method
49 audibleFX(); TextView (1)
50 //Call visual effects method
51 visualFX();
52 //Call vibrate effects method
53 touchFX();
54
55
} Stay in touch!
56 private void audibleFX() {
57 //Play sound file
58 mPlayer.start(); Email: Enter your email Subscribe
59 }
60
61 private void visualFX() {
62 //Set background with broken glass image
63 findViewById(R.id.background).setBackgroundResource(R.drawable.cracked_screen);
64 //Set title textview with color 0x6400ff00 Blog links
65 ((TextView)findViewById(R.id.title)).setTextColor(0x6400ff00);
66 //Set blurb textview with color 0x64ffffff
67 ((TextView)findViewById(R.id.blurb)).setTextColor(0x64ffffff);
Android Home
68 //Set button with color 0x64cdc9c9
69 ((Button)findViewById(R.id.button)).setBackgroundColor(0x64cdc9c9 Google Play
70 }
71 Java blog
72 private void touchFX() {
73 //Create vibrator object
74 Vibrator mv = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
75 //Vibrate for 500 MS
76
77 }
mv.vibrate(new long[]{ 0, 500, 0 }, -1);
About Me
78
79 protected void onDestroy() {
80 super.onDestroy(); Hi, welcome to Android Tutorial
81 // Release mediaplayer
82 if (mPlayer != null) { Blog. I am Udhay - a software
83 mPlayer.release(); engineer. Let me introduce myself
84 mPlayer = null;
85 } more formally, I’m a normal guy,
86 }
engineer by education who is
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
86 }
engineer by education who is
87 }
passionate about Programming and Internet.
Add vibrate permission in Androidmanifest.xml: Here I am writing about Android and lot about
1 <uses-permission android:name="android.permission.VIBRATE" /> developing simple android applications. Are you
new/beginner to Android programming and want
To know more about how to use vibration service in Android, see Android vibrate example
to join with me in the journey of learning Android
Demo: application development? You are in the right
Congratulations, We are done. place then :) Keep me posted with your valuable
Let us test the application: feedback and comments. Happy learning!
Right click on the project >> Run as >> Android application >> Choose emulator or device
Tap on the button and see what happens.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Entire project is zipped and is available for download. Unzip the downloaded
project and to import the project into eclipse, launch eclipse >> File >> Import.. >>
Choose downloaded project(How to import android project in eclipse). If you just
want to run the application in your mobile and see the output but don’t want to hit
your head with source code, download application(apk) file and install it in your
mobile device.
Download Source Code Download Application(apk)
*apk in Android is the installation file simliar to exe in windows.
I hope you enjoyed the post!!
Suggested posts for further reading
You might also like -
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Android Autocom plete Android JSON Web How to call Java w eb How to call asp.net
Textview Exam ple Service Tutorial service in android w eb service in android
Tw eet 3 Share 12 Like 12 Send Share
5 Comments
aravind
NOVEMBER 30, 2012
nice post
reply
Samuel
NOVEMBER 24, 2012
Hi I’ve followed your instruction and have recreated the app using Eclipse, only changing
minor bits such as the “android:text=” part into using a @string method (This was flagged
by Eclipse) and the file name of the main.xml
After finishing that I tried to run it on an emulator as well as my own Android device.
While at first it runs, it force quitted after playing the glass sound, without displaying the
cracked_glass png as well as any vibration.
I tried using your source code provided at the end of this guide and it works.
Any idea what I’ve done wrong?
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
reply
MrCleanX
OCTOBER 30, 2012
Great post! Great Blog! Just what I need to get rolling in Droid programming. Thanks, and
keep it up!
reply
Wiltshire
OCTOBER 19, 2012
My brother recommended I might like this blog. He was entirely right. This publish truly
made my day. You can not imagine just how a lot time I had spent for this information!
Thank you!
reply
g.gopikrishna
SEPTEMBER 25, 2012
how to remove ram memory in android device using java code or phonegap code .please
provide slolution for me
reply
Leave a Reply
Your email address will not be published. Required fields are marked *
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Name *
Email *
Website
Comment
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym
title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q
cite=""> <strike> <strong>
Submit Comment
If you like this post, please do click ‘Appreciate
Badge’
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com