Guest User

Untitled

a guest
Oct 29th, 2011
356
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  45. mBackgroundSound = new BackgroundSound();
  46.  
  47. }
  48.  
  49. public void onResume() {
  50. super.onResume();
  51. mBackgroundSound.execute(null);
  52.  
  53. }
  54.  
  55. public void onPause() {
  56. super.onPause();
  57. mBackgroundSound.cancel(true);
  58. }
  59.  
  60.  
  61. @Override
  62. public void onClick(View v) {
  63.  
  64. switch (v.getId()) {
  65.  
  66. case R.id.btnStart:
  67.  
  68. Intent intent = new Intent(this, BrzoRacunanjeActivity.class);
  69.  
  70. startActivity(intent);
  71.  
  72. break;
  73.  
  74. case R.id.btnInstrukcije:
  75.  
  76. Intent a = new Intent(this, InstrukcijeActivity.class);
  77.  
  78. startActivity(a);
  79.  
  80. break;
  81.  
  82. case R.id.btnRank:
  83.  
  84. Intent b = new Intent(this, RankPrikazActivity.class);
  85.  
  86. startActivity(b);
  87. break;
  88.  
  89. case R.id.btnIzlaz:
  90.  
  91. Intent c = new Intent(this, UcenjeActivity.class);
  92.  
  93. startActivity(c);
  94. break;
  95.  
  96. }
  97.  
  98. }
  99.  
  100.  
  101.  
  102. public class BackgroundSound extends AsyncTask<Void, Void, Void> {
  103.  
  104. protected Void doInBackground(Void... params) {
  105. MediaPlayer player = MediaPlayer.create(PocetnaActivity.this, R.raw.test_cbr);
  106. player.setLooping(true); // Set looping
  107. player.setVolume(100,100);
  108. player.start();
  109.  
  110. return null;
  111. }
  112.  
  113.  
  114.  
  115. }
  116.  
  117.  
  118. }
  119.  
  120.  
  121.  
RAW Paste Data