Proyek Iseng, KabarGembira.apk — Mastin Gooood

Taruhlah ini adalah sebuah proyek iseng menunggu buka puasa, haha. Karena terus terngiang dan semakin tidak bisa menolak viralnya iklan Kulit Manggis itu, maka bagi kamu yang pengen memanjakan syarafmu dengan jingle candu itu, silakan unduh APKnya disini:

Screenshot_2014-07-05-13-32-06
Untuk source code nya bisa diunduh disini (via Google Drive) , untuk Activity utama kira-kira seperti ini:

package org.panahbiru.kabargembira;

import java.io.IOException;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.Toast;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.view.View;
import android.view.View.OnClickListener;

public class MainActivity extends Activity {
	static MediaPlayer mPlayer;
	Button btnGood1;
	Button btnGood2;
	Button btnKabarGembira1;
	Button btnKabarGembira2;
	Button btnJadikan;
	Button btnPesona;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		btnGood1 = (Button) findViewById(R.id.mastin_good1);
		btnGood1.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Uri myUri1 = Uri.parse("android.resource://org.panahbiru.kabargembira/" + R.raw.mastingood1);
				mPlayer = new MediaPlayer();
				mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
				try {
					mPlayer.setDataSource(getApplicationContext(), myUri1);
				} catch (IllegalArgumentException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (SecurityException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					e.printStackTrace();
				}
				try {
					mPlayer.prepare();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				}
				mPlayer.start();
			}
		
		});
		
		btnGood2 = (Button) findViewById(R.id.mastin_good2);
		btnGood2.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Uri myUri1 = Uri.parse("android.resource://org.panahbiru.kabargembira/" + R.raw.mastingood2);
				mPlayer = new MediaPlayer();
				mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
				try {
					mPlayer.setDataSource(getApplicationContext(), myUri1);
				} catch (IllegalArgumentException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (SecurityException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					e.printStackTrace();
				}
				try {
					mPlayer.prepare();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				}
				mPlayer.start();
			}
		
		});
		
		btnKabarGembira1 = (Button) findViewById(R.id.kabar_gembira1);
		btnKabarGembira1.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				// Even you can refer resource in res/raw directory
				Uri myUri1 = Uri.parse("android.resource://org.panahbiru.kabargembira/" + R.raw.kabargembira1); 
				//Uri myUri1 = Uri.parse("file:///android_asset/kabar-gembira.mp3");
				mPlayer = new MediaPlayer();
				mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
				try {
					mPlayer.setDataSource(getApplicationContext(), myUri1);
				} catch (IllegalArgumentException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (SecurityException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					e.printStackTrace();
				}
				try {
					mPlayer.prepare();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				}
				mPlayer.start();
			}
		
		});
		
		btnKabarGembira2 = (Button) findViewById(R.id.kabar_gembira2);
		btnKabarGembira2.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Uri myUri1 = Uri.parse("android.resource://org.panahbiru.kabargembira/" + R.raw.kabargembira2);
				mPlayer = new MediaPlayer();
				mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
				try {
					mPlayer.setDataSource(getApplicationContext(), myUri1);
				} catch (IllegalArgumentException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (SecurityException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					e.printStackTrace();
				}
				try {
					mPlayer.prepare();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				}
				mPlayer.start();
			}
		
		});
		
		btnJadikan = (Button) findViewById(R.id.jadikan_hari);
		btnJadikan.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Uri myUri1 = Uri.parse("android.resource://org.panahbiru.kabargembira/" + R.raw.jadikanhariini);
				mPlayer = new MediaPlayer();
				mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
				try {
					mPlayer.setDataSource(getApplicationContext(), myUri1);
				} catch (IllegalArgumentException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (SecurityException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					e.printStackTrace();
				}
				try {
					mPlayer.prepare();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				}
				mPlayer.start();
			}
		
		});
		
		btnPesona = (Button) findViewById(R.id.penuh_pesona);
		btnPesona.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Uri myUri1 = Uri.parse("android.resource://org.panahbiru.kabargembira/" + R.raw.penuhpesona);
				mPlayer = new MediaPlayer();
				mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
				try {
					mPlayer.setDataSource(getApplicationContext(), myUri1);
				} catch (IllegalArgumentException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (SecurityException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					e.printStackTrace();
				}
				try {
					mPlayer.prepare();
				} catch (IllegalStateException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				} catch (IOException e) {
					Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
				}
				mPlayer.start();
			}
		
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	@SuppressWarnings("deprecation")
	public boolean onOptionsItemSelected(MenuItem item) {  
        switch (item.getItemId()) {
	        case R.id.action_settings:
	        	AlertDialog alertDialog = new AlertDialog.Builder(this).create();
	    		alertDialog.setTitle("Tentang Aplikasi");
	    		alertDialog.setIcon(R.drawable.ic_launcher);
	    		alertDialog.setMessage("Kabar Gembira untuk kita semua, kulit manggis kini ada ekstraknya." +
	    				"\n\n Wwkwkwk. (c) 2014 KandangSapi.");
	    		alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
	    		     public void onClick(final DialogInterface dialog, final int which) {
	    		     // TODO Auto-generated method stub
	    		         dialog.cancel();
	    		     }
	    		});
	    		alertDialog.show();
	        	return true;
	        	
	        case R.id.action_exit:
	        	AlertDialog.Builder alert = new AlertDialog.Builder(this);
        		alert.setMessage("Apakah anda ingin keluar ?");
        		alert.setCancelable(false);
        		alert.setPositiveButton("Ya", new DialogInterface.OnClickListener() {
        		      public void onClick(DialogInterface dialog, int id) {
	        		      finish();
        		      }
        		});
        		alert.setNegativeButton("Tidak", new DialogInterface.OnClickListener() {
        			  public void onClick(DialogInterface dialog, int id) {
        		      // TODO Auto-generated method stub
        				  dialog.cancel();
        		      }
        		});
        		alert.show();
        		return true;
        }
		return false;
	}
}

About the Author

Ifhtul Emka

Petani Sistem Informasi, tukang las plugin & themes Wordpress. Co-Founder SistemInformasi.biz. Saat ini aktif sebagai konsultan development sistem informasi beberapa kampus, sekaligus Developer & kontributor di OpenMandriva Linux. Bekerja sehari-hari di ICT Center Unnes sebagai tukang sapu Programmer.

No comments

Leave a Reply

%d bloggers like this: