Android app forces semi reboot / crash on some phones
<p>The app in questions seems to work fine, but when you use the back button on the phone to exit the app sometimes it crashes the phone. It doesnt actually turn it off but runs the boot up animation again.</p>

<p>Here is an excert I have from logcat, this segment is repeated a lot of times. The app is a quiz so only relies on a database.</p>

<p>Any advice on how to resolve this would be greatly appreciated.</p>

<pre><code>11-20 15:47:40.236: DEBUG/WifiStateTracker(1505): get mPhoneStateListener
11-20 15:47:41.087: DEBUG/SensorService(1505): enable: get sensor name = MPL accel
11-20 15:47:41.087: DEBUG/Sensors(1505): handle : 4 en: 1, v010.0 - Try to resolve lock issue
11-20 15:47:41.087: DEBUG/Sensors(1505): lock_status = 58
11-20 15:47:41.087: DEBUG/Sensors(1505): Andy: MPLSensor::enable: lock1
11-20 15:47:41.087: DEBUG/Sensors(1505): mEnabled = 0x10
11-20 15:47:41.087: DEBUG/Sensors(1505): set_power_states++: enabled_sensors: 16 dmp_started: 0
11-20 15:47:41.087: DEBUG/Sensors(1505): Before if statment: cs:0 rs:1 en_ped:0 da_ped:0 en_g:0 da_g:0
11-20 15:47:41.087: DEBUG/Sensors(1505): STOP timerirq_1
11-20 15:47:41.107: DEBUG/Sensors(1505): Starting DMP
11-20 15:47:41.127: INFO/(1505): mpu3050_resume: Resuming to 0070
11-20 15:47:41.127: DEBUG/Sensors(1505): Exit: Starting DMP
11-20 15:47:41.127: DEBUG/Sensors(1505): set_power_states--
11-20 15:47:41.127: DEBUG/Sensors(1505): Andy: MPLSensor::enable: unlock1
11-20 15:47:41.127: DEBUG/Sensors(1505): MPLSensor::enable--1
11-20 15:47:41.127: DEBUG/SensorService(1505): SensorDevice::activate--: handle = 0x4, enabled = 0x1
11-20 15:47:41.127: DEBUG/SensorService(1505): enable: sensor-&gt;activate return value = 0x0
11-20 15:47:41.127: DEBUG/SensorService(1505): enable: calling mActiveSensors.add(handle, rec) = (0x4, 0x7a40e8)
11-20 15:47:41.127: DEBUG/SensorService(1505): enable: mActiveConnections.indexOf(connection) = 0x0
11-20 15:47:41.127: DEBUG/SensorService(1505): pid=1505, uid=1000
11-20 15:47:41.127: DEBUG/SensorService(1505): disable: get sensor name = MPL accel
11-20 15:47:41.127: DEBUG/SensorService(1505): disable: sensor = 0x326a98
11-20 15:47:41.127: DEBUG/Sensors(1505): handle : 4 en: 0, v010.0 - Try to resolve lock issue
11-20 15:47:41.127: DEBUG/Sensors(1505): lock_status = 63
11-20 15:47:41.127: DEBUG/Sensors(1505): Andy: MPLSensor::enable: lock1
11-20 15:47:41.127: WARN/MPL-sup(1505): MLGetAKMComassStatus, gAKMCompassStatus = 0
11-20 15:47:41.127: DEBUG/Sensors(1505): mEnabled = 0x0
11-20 15:47:41.127: DEBUG/Sensors(1505): set_power_states++: enabled_sensors: 0 dmp_started: 1
11-20 15:47:41.127: DEBUG/Sensors(1505): Before if statment: cs:0 rs:0 en_ped:0 da_ped:0 en_g:0 da_g:0
11-20 15:47:41.127: DEBUG/Sensors(1505): Stopping DMP
11-20 15:47:41.127: INFO/(1505): mpu3050_suspend: suspending sensors to 0000
11-20 15:47:41.127: INFO/(1505): mpu3050_suspend: Will resume next to 0070
11-20 15:47:41.127: DEBUG/Sensors(1505): inside if(s_use_timerirq)
11-20 15:47:41.157: DEBUG/Sensors(1505): set_power_states--
11-20 15:47:41.157: DEBUG/Sensors(1505): Andy: MPLSensor::enable: unlock1
11-20 15:47:41.157: DEBUG/Sensors(1505): MPLSensor::enable--1
11-20 15:47:41.157: DEBUG/SensorService(1505): SensorDevice::activate--: handle = 0x4, enabled = 0x0
11-20 15:47:41.157: DEBUG/SensorService(1505): pid=1505, uid=1000
11-20 15:47:41.167: DEBUG/SensorService(1505): enable: get sensor name = MPL accel
11-20 15:47:41.167: DEBUG/Sensors(1505): handle : 4 en: 1, v010.0 - Try to resolve lock issue
11-20 15:47:41.167: DEBUG/Sensors(1505): lock_status = 58
11-20 15:47:41.167: DEBUG/Sensors(1505): Andy: MPLSensor::enable: lock1
11-20 15:47:41.167: DEBUG/Sensors(1505): mEnabled = 0x10
11-20 15:47:41.167: DEBUG/Sensors(1505): set_power_states++: enabled_sensors: 16 dmp_started: 0
11-20 15:47:41.167: DEBUG/Sensors(1505): Before if statment: cs:0 rs:1 en_ped:0 da_ped:0 en_g:0 da_g:0
11-20 15:47:41.167: DEBUG/Sensors(1505): STOP timerirq_1
11-20 15:47:41.187: DEBUG/Sensors(1505): Starting DMP
11-20 15:47:41.207: INFO/(1505): mpu3050_resume: Resuming to 0070
</code></pre>

<p>Edit:</p>

<p>The way I can guarantee this to happen is as follows.
From activity A(home screen) open activity B (Question page) click an option and that takes you to activity C(Answer page) Here you click next and go back to activity B.
So B -> C -> B</p>

<p>If I go through this process a lot answering around 10 - 15 questions. When I click back to A i get the logcat output above. Then when I click back from the home page (A) it does this reboot thing.</p>

<p>I have a suspicion that this is something to do with how I am handling the intents when looping.</p>

<p>Extract from B that forward to C</p>

<pre><code>public void answer(int picked){
    Intent intent = new Intent(this, package.Answer.class);
    Bundle b = new Bundle();
    b.putInt("PICKED", picked);
    b.putInt("CORRECT", correct);
    b.putString("RANDOM", "nextq");
    intent.putExtras(b);
        this.startActivityForResult(intent, requestCode);
</code></pre>

<p>}</p>

<p>Extract from C that takes you back to B</p>

<pre><code>public void nextquestion(){
    Intent Intent = new Intent(this, package.Question.class);
    startActivity(Intent);
    this.setResult(1, Intent);
    this.finish();
}
</code></pre>

<p>Extract from B when returning from C</p>

<pre><code>public void onActivityResult(int requestCode, int resultCode, Intent data) {
    this.finish();
}
</code></pre>
