package com.example.sadaf;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.support.v4.app.Fragment.SavedState;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Morvarid extends Activity {
public static Object MediaPlayer = null;
static boolean xx,cc;
static int dd;
public static void main1(Object object){
}
public MediaPlayer player;
public android.media.MediaPlayer mediaPlayer;
private Intent[] intent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dd=2;
xx=true;
setContentView(R.layout.activity_morvarid);
if (getIntent().getBooleanExtra("EXIT", false)) {
dd=2;
xx=true;
//startActivities(intent);
//super.onRestart();
//super.onResume();
///super.onPause();
//super.onStop();
//super.onDestroy();
finish();
}
Button b2=(Button)findViewById(R.id.button1);
b2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(xx==false){
player = android.media.MediaPlayer.create(Morvarid.this, R.raw.barun_sut);
player.setVolume(100,100);
player.start();
xx=true;
dd=1;
}
else{
player.stop();
player = android.media.MediaPlayer.create(Morvarid.this, R.raw.barun_sut);
player.setVolume(100,100);
player.start();
player.release();
xx=true;
dd=1;
}
}
});
}
protected void onSaveInstanceState() {
super.onSaveInstanceState(null);
return;
}
protected void onRestoreInstanceState() {
super.onRestoreInstanceState(null);
return;
}
@Override
protected void onPause() {
super.onPause();
xx=true;
dd=2;
return;
}
@Override
protected void onRestart() {
super.onRestart();
return;
}
@Override
protected void onStop(){
super.onStop();
xx=true;
dd=2;
return;
}
protected void onDestory(){
super.onDestroy();
xx=true;
dd=2;
return;
}
@Override
public void onBackPressed() {
if(dd<2){
player.stop();
Intent intent = new Intent(Morvarid.this,MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
}
else
{
Intent intent = new Intent(Morvarid.this,MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
}
}
}