Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.test.brzoracunanje;
- import android.app.Activity;
- import android.content.Intent;
- import android.media.MediaPlayer;
- import android.os.AsyncTask;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.KeyEvent;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.TextView;
- import android.widget.Toast;
- public class PocetnaActivity extends Activity implements OnClickListener {
- TextView tvNaslov;
- ImageView imgLogo;
- Button btnStart, btnInstrukcije, btnRank, btnIzlaz;
- //MediaPlayer mMediaPlayer;
- BackgroundSound mBackgroundSound;
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.pocetna);
- tvNaslov = (TextView) findViewById(R.id.tvRacunalica);
- imgLogo = (ImageView) findViewById(R.id.imageView1);
- btnStart = (Button) findViewById(R.id.btnStart);
- btnInstrukcije = (Button) findViewById(R.id.btnInstrukcije);
- btnRank = (Button) findViewById(R.id.btnRank);
- btnIzlaz = (Button) findViewById(R.id.btnIzlaz);
- btnStart.setOnClickListener(this);
- btnRank.setOnClickListener(this);
- btnInstrukcije.setOnClickListener(this);
- btnIzlaz.setOnClickListener(this);
- //Intent svc=new Intent(this, BackgroundSoundService.class);
- //startService(svc);
- }
- public void onResume() {
- super.onResume();
- mBackgroundSound = new BackgroundSound();
- mBackgroundSound.execute(null);
- }
- public void onPause() {
- super.onPause();
- mBackgroundSound.cancel(true);
- }
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.btnStart:
- Intent intent = new Intent(this, BrzoRacunanjeActivity.class);
- startActivity(intent);
- break;
- case R.id.btnInstrukcije:
- Intent a = new Intent(this, InstrukcijeActivity.class);
- startActivity(a);
- break;
- case R.id.btnRank:
- Intent b = new Intent(this, RankPrikazActivity.class);
- startActivity(b);
- break;
- case R.id.btnIzlaz:
- Intent c = new Intent(this, UcenjeActivity.class);
- startActivity(c);
- break;
- }
- }
- public class BackgroundSound extends AsyncTask<Void, Void, Void> {
- MediaPlayer mMediaPlayer;
- protected void onPreExecute() {
- mMediaPlayer = MediaPlayer.create(PocetnaActivity.this, R.raw.test_cbr);
- }
- protected Void doInBackground(Void... params) {
- mMediaPlayer.setLooping(true); // Set looping
- mMediaPlayer.setVolume(100,100);
- mMediaPlayer.start();
- return null;
- }
- protected void onCancelled(Void v) {
- mMediaPlayer.stop();
- mMediaPlayer.release();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement