Overriding the idle timeout in android
<p>I am building an app and I'd like to override the idle timeout of the app. I'd like it to never timeout, similar to most games. Does anyone know how you'd do this. I've been trolling the internet for a while now and I'm not sure.</p>

<p>iPhone is idleTimeout = NO;</p>

<p>Super easy, is there any global setting like that I can hit in Android? I'm not seeing anything on android developers, or in any of the web pages I've looked at.</p>

<p>Thanks a ton!</p>

<p>I have a second piggy back question. I also have a memory leak. Here's the code
[code]
package fourguys.testing.IntentTest;</p>

<p>import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.media.MediaPlayer;
import android.media.AudioManager;
import android.content.Context;</p>

<p>public class CanvasDrawingActivity extends  Activity   {</p>

<pre><code>private static final int FIRE = 0;
private int initVolume = 0;
private Handler handler;
private MyCanvas v;
private MediaPlayer mp;
private AudioManager am;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    am = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE);

        // this method gets the current volume setting for music
        initVolume = am.getStreamVolume(AudioManager.STREAM_MUSIC);


        am.setStreamVolume(AudioManager.STREAM_MUSIC,100,AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);

    mp = MediaPlayer.create(this, R.raw.test);

    makeHandler();
    v =new MyCanvas(this);
    new Thread(new Runnable(){
        @Override
        public void run() {
            while(true)
                handler.sendEmptyMessage(FIRE); 
        }}).start();
    setContentView(v);
    mp.setLooping(true);
    mp.start();
}
private void makeHandler()
{
    handler  = new Handler(){

        @Override
        public void handleMessage(Message msg) {
            switch(msg.what)
            {
            case FIRE:
            {
                v.invalidate();
                break;
            }
            }
        }

    };
}
protected void onPause() {
    super.onPause();
    mp.stop();
}
protected void onFinish() {
    mp.stop();
}

}
</code></pre>

<p>[/code]</p>

<p>and this:</p>

<p>[code]
package fourguys.testing.IntentTest;</p>

<p>import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.view.WindowManager;</p>

<p>public class IntentTest extends Activity {
    /** Called when the activity is first created. */</p>

<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    //reciever intentReceiver = new reciever();

   // IntentFilter intentFilter = new IntentFilter("com.app.REC");

    //registerReceiver(intentReceiver, intentFilter); 
    Button b = (Button)this.findViewById(R.id.endButton);
    b.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(IntentTest.this,CanvasDrawingActivity.class);
            startActivity(i);

        }
     });
 }
// the onPause method get called when the app is either being hidden or being closed so this the place where we would want to clean anything up like stoping the media player.
@Override
protected void onPause()
{
    super.onPause();
}
}
</code></pre>

<p>[/code]</p>

<p>I run the app and it gets wonky on exit. It locks the handset and causes the battery to run hot. I need to pull the battery physically to reboot. Any thoughts as to why that might be? It runs fantastically on the emulator. Should I be using onFinish instead, or am I not cleaning something up and I'm missing it?</p>
