Android Open Source - dynamic-sound-android Main Activity






From Project

Back to project page dynamic-sound-android.

License

The source code is released under:

MIT License

If you think the Android project dynamic-sound-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.tackmobile.spacerocks;
/*from  w  w w  .  j a  v  a2s.c  o  m*/
import org.puredata.android.io.PdAudio;

import com.tackmobile.spacerocks.audio.PdInterface;

import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;

public class MainActivity extends Activity {
  
  protected static final long FRAME_RATE = 20;
  
  GameBoard gameBoard;
  Handler handler = new Handler();

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    PdInterface.getInstance().initialize(this);
  }

  @Override protected void onStart() {
    super.onStart();
    PdAudio.startAudio(this);
  }

  @Override protected void onStop() {
    PdAudio.stopAudio();
    super.onStop();
  }

  @Override protected void onDestroy() {
    PdInterface.getInstance().destroy();
    super.onDestroy();
  }

  @Override protected void onResume() {
    super.onResume();
    gameBoard = (GameBoard)findViewById(R.id.game_board);
    handler.post(frame);
  }
  
  Runnable frame = new Runnable() {
    @Override public void run() {
      gameBoard.onFrame();
      handler.postDelayed(frame, FRAME_RATE);
    }
  };

}




Java Source Code List

com.tackmobile.androidpiano.MainActivity.java
com.tackmobile.androidpiano.audio.PdInterface.java
com.tackmobile.androidpiano.view.Key.java
com.tackmobile.androidpiano.view.KeysView.java
com.tackmobile.spacerocks.GameBoard.java
com.tackmobile.spacerocks.MainActivity.java
com.tackmobile.spacerocks.audio.PdInterface.java
com.tackmobile.spacerocks.models.Asteroid.java
com.tackmobile.spacerocks.models.Missile.java