Assalammualaikum wr,wb kali ini saya akan mempost
project UAS saya berbasis aplikasi yang menggunakan eclipse, Aplikasi
yang saya buat adalah Zihir almasurot sehingga kalian bisa mendengarkan Zikir setiap pagi dan petang langsung saja tentu langkah pertama adalah membuka eclipse lalu
membuat main activity baru disini saya buat berikut langkah – langkahnya :
Deskripsi Perancangan dan pembuatan
Project :
1. main activity
2. sugro activity
3. kubroactivity
-->BERIKUT CODINGAN MAINACTIVITY
package com.example.uma161011401315;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements OnClickListener {
Button pagi;
Button petang;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pagi = (Button) findViewById(R.id.satu);
petang = (Button) findViewById(R.id.dua);
pagi.setOnClickListener(this);
petang.setOnClickListener(this);
}
@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;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (v==pagi){
Intent intent= new Intent(this, Sugro.class);
startActivity(intent);
}
if (v==petang){
Intent intent= new Intent(this,Kubro.class);
startActivity(intent);
}; } }
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements OnClickListener {
Button pagi;
Button petang;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pagi = (Button) findViewById(R.id.satu);
petang = (Button) findViewById(R.id.dua);
pagi.setOnClickListener(this);
petang.setOnClickListener(this);
}
@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;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (v==pagi){
Intent intent= new Intent(this, Sugro.class);
startActivity(intent);
}
if (v==petang){
Intent intent= new Intent(this,Kubro.class);
startActivity(intent);
}; } }
HASIL KERJA SCREENSHOOT
2. buat sugro_activity
-->BERIKUT CODINGAN SUGRO ACTIVITY
package com.example.uma161011401315;
import android.app.Activity;
import android.app.AlertDialog;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Sugro extends Activity {
private Button play;
private Button pause;
private Button stop;
private MediaPlayer mp;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_sugro);
pause= (Button)findViewById(R.id.pause);
play = (Button)findViewById(R.id.play);
stop = (Button)findViewById(R.id.stop);
pause.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
pause();
}
});
play.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
play();
}
});
stop.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
stop();
}
});
setup();
}
@Override
public void onDestroy() {
super.onDestroy();
if (stop.isEnabled()){
stop();
}
}
public void onCompletion(MediaPlayer mp) {
stop();
}
private void play() {
mp.start();
play.setEnabled(false);
pause.setEnabled(true);
stop.setEnabled(true);
}
private void stop(){
mp.stop();
pause.setEnabled(false);
stop.setEnabled(false);
try { mp.prepare();
mp.seekTo(0);
play.setEnabled(true);
} catch (Throwable t) {
goBlooey(t);
}
}
private void pause() {
mp.pause();
play.setEnabled(true);
pause.setEnabled(false);
stop.setEnabled(true);
}
private void loadClip() {
try { mp=MediaPlayer.create(this, R.raw.cobaa);
mp.setOnCompletionListener ((OnCompletionListener) this);
} catch (Throwable t) {
goBlooey(t);
}
}
private void setup() {
loadClip();
play.setEnabled(true);
pause.setEnabled(false);
stop.setEnabled(false);
}
private void goBlooey(Throwable t) {
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder .setTitle("Exception!") .setMessage(t.toString()) .setPositiveButton("OK", null) .show();
}
}
import android.app.Activity;
import android.app.AlertDialog;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Sugro extends Activity {
private Button play;
private Button pause;
private Button stop;
private MediaPlayer mp;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_sugro);
pause= (Button)findViewById(R.id.pause);
play = (Button)findViewById(R.id.play);
stop = (Button)findViewById(R.id.stop);
pause.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
pause();
}
});
play.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
play();
}
});
stop.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
stop();
}
});
setup();
}
@Override
public void onDestroy() {
super.onDestroy();
if (stop.isEnabled()){
stop();
}
}
public void onCompletion(MediaPlayer mp) {
stop();
}
private void play() {
mp.start();
play.setEnabled(false);
pause.setEnabled(true);
stop.setEnabled(true);
}
private void stop(){
mp.stop();
pause.setEnabled(false);
stop.setEnabled(false);
try { mp.prepare();
mp.seekTo(0);
play.setEnabled(true);
} catch (Throwable t) {
goBlooey(t);
}
}
private void pause() {
mp.pause();
play.setEnabled(true);
pause.setEnabled(false);
stop.setEnabled(true);
}
private void loadClip() {
try { mp=MediaPlayer.create(this, R.raw.cobaa);
mp.setOnCompletionListener ((OnCompletionListener) this);
} catch (Throwable t) {
goBlooey(t);
}
}
private void setup() {
loadClip();
play.setEnabled(true);
pause.setEnabled(false);
stop.setEnabled(false);
}
private void goBlooey(Throwable t) {
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder .setTitle("Exception!") .setMessage(t.toString()) .setPositiveButton("OK", null) .show();
}
}
HASIL SCREENSHOOT
3. buat kubro_activity
-->BERIKUT CODINGAN KUBRO ACTIVITY
package com.example.uma161011401315;
import android.app.Activity;
import android.app.AlertDialog;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Kubro extends Activity {
private Button play;
private Button pause;
private Button stop;
private MediaPlayer mp;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_kubro);
pause= (Button)findViewById(R.id.pause);
play = (Button)findViewById(R.id.play);
stop = (Button)findViewById(R.id.stop);
pause.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
pause();
}
});
play.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
play();
}
});
stop.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
stop();
}
});
setup();
}
@Override
public void onDestroy() {
super.onDestroy();
if (stop.isEnabled()){
stop();
}
}
public void onCompletion(MediaPlayer mp) {
stop();
}
private void play() {
mp.start();
play.setEnabled(false);
pause.setEnabled(true);
stop.setEnabled(true);
}
private void stop(){
mp.stop();
pause.setEnabled(false);
stop.setEnabled(false);
try { mp.prepare();
mp.seekTo(0);
play.setEnabled(true);
} catch (Throwable t) {
goBlooey(t);
}
}
private void pause() {
mp.pause();
play.setEnabled(true);
pause.setEnabled(false);
stop.setEnabled(true);
}
private void loadClip() {
try { mp=MediaPlayer.create(this, R.raw.dulu);
mp.setOnCompletionListener ((OnCompletionListener) this);
} catch (Throwable t) {
goBlooey(t);
}
}
private void setup() {
loadClip();
play.setEnabled(true);
pause.setEnabled(false);
stop.setEnabled(false);
}
private void goBlooey(Throwable t) {
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder .setTitle("Exception!") .setMessage(t.toString()) .setPositiveButton("OK", null) .show();
}
}
import android.app.Activity;
import android.app.AlertDialog;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Kubro extends Activity {
private Button play;
private Button pause;
private Button stop;
private MediaPlayer mp;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_kubro);
pause= (Button)findViewById(R.id.pause);
play = (Button)findViewById(R.id.play);
stop = (Button)findViewById(R.id.stop);
pause.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
pause();
}
});
play.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
play();
}
});
stop.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
stop();
}
});
setup();
}
@Override
public void onDestroy() {
super.onDestroy();
if (stop.isEnabled()){
stop();
}
}
public void onCompletion(MediaPlayer mp) {
stop();
}
private void play() {
mp.start();
play.setEnabled(false);
pause.setEnabled(true);
stop.setEnabled(true);
}
private void stop(){
mp.stop();
pause.setEnabled(false);
stop.setEnabled(false);
try { mp.prepare();
mp.seekTo(0);
play.setEnabled(true);
} catch (Throwable t) {
goBlooey(t);
}
}
private void pause() {
mp.pause();
play.setEnabled(true);
pause.setEnabled(false);
stop.setEnabled(true);
}
private void loadClip() {
try { mp=MediaPlayer.create(this, R.raw.dulu);
mp.setOnCompletionListener ((OnCompletionListener) this);
} catch (Throwable t) {
goBlooey(t);
}
}
private void setup() {
loadClip();
play.setEnabled(true);
pause.setEnabled(false);
stop.setEnabled(false);
}
private void goBlooey(Throwable t) {
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder .setTitle("Exception!") .setMessage(t.toString()) .setPositiveButton("OK", null) .show();
}
}
HASIL SCREENSHOOT