package com.games.andronoid;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.preference.PreferenceManager;

public class GameActivity extends Activity {
	
    private PowerManager mPowerManager;
    private WakeLock mWakeLock;
    private GameView mGameView;
    
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);
        mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass()
                .getName());
        
        Intent inte = getIntent();
        Bundle bn = inte.getExtras();
        
        String sMosaicName = (String)bn.get("com.games.andronoid.mosaic");
        String sBackGroundFile = (String)bn.get("com.games.andronoid.background");
        String sMusicFile = (String)bn.get("com.games.andronoid.music");
        
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
        
        int nFriction = settings.getInt("friction", 30);
        int nMass = settings.getInt("mass", 50);
        boolean bMusic = settings.getBoolean("music", true);
        String sDifficulty = settings.getString("difficulty", "normal"); 
        
        mGameView = new GameView(this, sMosaicName, sBackGroundFile, sMusicFile, nFriction, nMass, bMusic, sDifficulty);
        setContentView(mGameView);
        
    }
    
    @Override
    protected void onResume() {
        super.onResume();
        /*
         * when the activity is resumed, we acquire a wake-lock so that the
         * screen stays on, since the user will likely not be fiddling with the
         * screen or buttons.
         */
        mWakeLock.acquire();

		mGameView.startGame();
    }

    @Override
    protected void onPause() {
        super.onPause();
        /*
         * When the activity is paused, we make sure to stop the simulation,
         * release our sensor resources and wake locks
         */

        // Stop the simulation
        mGameView.stopGame();

        // and release our wake-lock
        mWakeLock.release();
    }
    
}
@@ -23,16 +23,76 @@
 onoid;%0A%0A
+import java.io.FileDescriptor;%0Aimport java.io.IOException;%0A%0A
 import a
@@ -112,16 +112,16 @@
 tivity;%0A
-
 import a
@@ -185,16 +185,50 @@
 rences;%0A
+import android.media.MediaPlayer;%0A
 import a
@@ -515,16 +515,49 @@
 meView;%0A
+    private MediaPlayer mPlayer;%0A
     %0A%09/*
@@ -716,32 +716,123 @@
 State);%0A        
+        %0A    %7D%0A    %0A    @Override%0A    protected void onResume() %7B%0A        super.onResume();
 %0A        mPowerM
@@ -1852,100 +1852,8 @@
 w);%0A
-        %0A    %7D%0A    %0A    @Override%0A    protected void onResume() %7B%0A        super.onResume();%0A
     
@@ -2086,17 +2086,708 @@
 uire();%0A
+        /*%0A        MediaPlayer mediaPlayer = new MediaPlayer(); //MediaPlayer.create(this,getAssets().open(%22track.mp3%22));%0A        try %7B%0A        %09FileDescriptor fd = new FileDescriptor();%0A        %09%0A%09%09%09mediaPlayer.setDataSource(fd);//.setDataSource(%22track.mp3%22);%0A%09%09%7D catch (IllegalArgumentException e) %7B%0A%09%09%09// TODO Auto-generated catch block%0A%09%09%09e.printStackTrace();%0A%09%09%7D catch (IllegalStateException e) %7B%0A%09%09%09// TODO Auto-generated catch block%0A%09%09%09e.printStackTrace();%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09// TODO Auto-generated catch block%0A%09%09%09e.printStackTrace();%0A%09%09%7D*/%0A        %0A        mPlayer = MediaPlayer.create(this, R.raw.kick);        %0A        mPlayer.setLooping(true);%0A        mPlayer.start();
 %0A
-
 %09%09mGameV
@@ -3036,16 +3036,40 @@
     */%0A%0A
+        mPlayer.stop();%0A
         

resolve issue with home button (application crashed, when push 'Home', than again launch application