Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.abhi.app;
- import java.io.IOException;
- import android.app.Activity;
- import android.app.WallpaperManager;
- import android.media.MediaPlayer;
- import android.media.MediaPlayer.OnCompletionListener;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.Toast;
- public class helloworld extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- Button button = (Button) findViewById(R.id.button01);
- final WallpaperManager wm = WallpaperManager.getInstance(this); //for wallpaper
- final MediaPlayer mp = MediaPlayer.create(helloworld.this, R.raw.devd); //for audio playback
- button.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- try {
- wm.setStream(getResources().openRawResource(R.raw.maal)); //set wallpaper
- mp.start(); //play music
- } catch(IOException e) {
- e.printStackTrace();
- }
- mp.setOnCompletionListener(new OnCompletionListener(){
- public void onCompletion(MediaPlayer mp) {
- Toast.makeText(helloworld.this, "Ma Chuda!", Toast.LENGTH_LONG).show();
- }
- });
- Toast.makeText(helloworld.this, "You were just Pranked! Check wallpaper to find out how badly.", Toast.LENGTH_LONG).show();
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment