View difference between Paste ID: jzw2j9WR and nzU674FZ
SHOW: | | - or go back to the newest paste.
1
package com.test.brzoracunanje;
2
3
import android.app.Activity;
4
import android.content.Intent;
5
import android.media.MediaPlayer;
6
import android.os.AsyncTask;
7
import android.os.Bundle;
8
import android.util.Log;
9
import android.view.KeyEvent;
10
import android.view.View;
11
import android.view.View.OnClickListener;
12
import android.widget.Button;
13
import android.widget.ImageView;
14
import android.widget.TextView;
15
import android.widget.Toast;
16
17
public class PocetnaActivity extends Activity implements OnClickListener {
18
19
20
	TextView tvNaslov;
21
	ImageView imgLogo;
22
	Button btnStart, btnInstrukcije, btnRank, btnIzlaz;
23
	//MediaPlayer mMediaPlayer;
24
	BackgroundSound mBackgroundSound;
25
26
	public void onCreate(Bundle savedInstanceState) {
27
		super.onCreate(savedInstanceState);
28
		setContentView(R.layout.pocetna);
29
30
		tvNaslov = (TextView) findViewById(R.id.tvRacunalica);
31
		imgLogo = (ImageView) findViewById(R.id.imageView1);
32
		btnStart = (Button) findViewById(R.id.btnStart);
33
		btnInstrukcije = (Button) findViewById(R.id.btnInstrukcije);
34
		btnRank = (Button) findViewById(R.id.btnRank);
35
		btnIzlaz = (Button) findViewById(R.id.btnIzlaz);
36
37
		btnStart.setOnClickListener(this);
38
		btnRank.setOnClickListener(this);
39
		btnInstrukcije.setOnClickListener(this);
40
		btnIzlaz.setOnClickListener(this);
41
42
		//Intent svc=new Intent(this, BackgroundSoundService.class);
43
		//startService(svc);
44-
		
44+
45-
		 mBackgroundSound = new BackgroundSound();
45+
46
	
47
    public void onResume() {
48
	    super.onResume();
49
 	    mBackgroundSound = new BackgroundSound();
50
	     mBackgroundSound.execute(null);
51
	      
52
	    }
53
	    
54
	    public void onPause() {
55
	    	super.onPause();
56
	        mBackgroundSound.cancel(true);
57
	    }
58
	
59
	
60
	@Override
61
	public void onClick(View v) {
62
63
		switch (v.getId()) {
64
65
		case R.id.btnStart:
66
67
			Intent intent = new Intent(this, BrzoRacunanjeActivity.class);
68
69
			startActivity(intent);
70
71
			break;
72
73
		case R.id.btnInstrukcije:
74
75
			Intent a = new Intent(this, InstrukcijeActivity.class);
76
77
			startActivity(a);
78
79
			break;
80
81
		case R.id.btnRank:
82
83
			Intent b = new Intent(this, RankPrikazActivity.class);
84
85
			startActivity(b);
86
			break;
87
88
		case R.id.btnIzlaz:
89
90
			Intent c = new Intent(this, UcenjeActivity.class);
91
92
			startActivity(c);
93
			break;
94
95
		}
96
97
	}
98
	
99
	
100
	
101
	public class BackgroundSound extends AsyncTask<Void, Void, Void> {
102
            MediaPlayer mMediaPlayer;
103
	    protected void onPreExecute() {
104
		mMediaPlayer = MediaPlayer.create(PocetnaActivity.this, R.raw.test_cbr); 
105-
	        MediaPlayer player = MediaPlayer.create(PocetnaActivity.this, R.raw.test_cbr); 
105+
106-
	        player.setLooping(true); // Set looping 
106+
107-
	        player.setVolume(100,100); 
107+
	        mMediaPlayer.setLooping(true); // Set looping 
108-
	        player.start(); 
108+
	        mMediaPlayer.setVolume(100,100); 
109
	        mMediaPlayer.start(); 
110
	        return null;
111
	    }
112
	    protected void onCancelled(Void v) {
113
		mMediaPlayer.stop();
114
		mMediaPlayer.release();
115
 	    }
116
	
117
118
	}
119
120
	
121
}
122
123
124
125