bikerabhinav

wallpaper.apk

Feb 19th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. package com.abhi.app;
  2.  
  3. import java.io.IOException;
  4.  
  5. import android.app.Activity;
  6. import android.app.WallpaperManager;
  7. import android.media.MediaPlayer;
  8. import android.media.MediaPlayer.OnCompletionListener;
  9. import android.os.Bundle;
  10. import android.view.View;
  11. import android.view.View.OnClickListener;
  12. import android.widget.Button;
  13. import android.widget.Toast;
  14.  
  15. public class helloworld extends Activity {
  16.     /** Called when the activity is first created. */
  17.     @Override
  18.     public void onCreate(Bundle savedInstanceState) {
  19.         super.onCreate(savedInstanceState);
  20.         setContentView(R.layout.main);
  21.         Button button = (Button) findViewById(R.id.button01);
  22.     final WallpaperManager wm = WallpaperManager.getInstance(this); //for wallpaper
  23.     final MediaPlayer mp = MediaPlayer.create(helloworld.this, R.raw.devd); //for audio playback
  24.         button.setOnClickListener(new OnClickListener() {
  25.             public void onClick(View v) {
  26.                 try {
  27.                     wm.setStream(getResources().openRawResource(R.raw.maal)); //set wallpaper
  28.                     mp.start(); //play music
  29.                 } catch(IOException e) {
  30.                     e.printStackTrace();
  31.                 }
  32.                 mp.setOnCompletionListener(new OnCompletionListener(){
  33.                     public void onCompletion(MediaPlayer mp) {
  34.                                 Toast.makeText(helloworld.this, "Ma Chuda!", Toast.LENGTH_LONG).show();
  35.                     }
  36.                 });
  37.                 Toast.makeText(helloworld.this, "You were just Pranked! Check wallpaper to find out how badly.", Toast.LENGTH_LONG).show();
  38.             }
  39.         });
  40.     }
  41.    
  42. }
Advertisement
Add Comment
Please, Sign In to add comment