Android应用程序强制在某些手机上重启/崩溃

时间:2011-11-22 15:09:27

标签: java android

问题中的应用程序似乎工作正常,但当您使用手机上的后退按钮退出应用程序时,它有时会崩溃手机。它实际上并没有关闭它,而是再次运行启动动画。

这是我从logcat获得的一个例外,这段重复了很多次。该应用程序是一个测验,因此只依赖于数据库。

非常感谢任何有关如何解决此问题的建议。

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->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

编辑:

我可以保证这种情况发生的方式如下。 从活动A(主屏幕)打开活动B(问题页面)单击选项,然后转到活动C(答案页面)在此单击下一步并返回到活动B. 所以B - > C - >乙

如果我经历这个过程,很多人会回答大约10到15个问题。当我点击返回A时,我得到上面的logcat输出。然后,当我从主页(A)单击回来时,它会执行此重新启动操作。

我怀疑这与我在循环时如何处理意图有关。

从B提取,转发到C

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);

}

从C中提取,将您带回B

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

从C

返回时从B中提取
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    this.finish();
}

1 个答案:

答案 0 :(得分:1)

在你的活动C中,摆脱startActivity。您所需要的只是setResult(int, intent)。在我们处理此问题时,请将您的变量名称更改为小写intent。仅在引用类型时使用大写的Intent

此外,如果您在获得结果后只是onActivityResult finish,活动B中Activity的重点是什么?