Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android应用程序在某些手机上强制半重启/崩溃_Java_Android - Fatal编程技术网

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

Java Android应用程序在某些手机上强制半重启/崩溃,java,android,Java,Android,问题中的应用程序似乎工作正常,但当您使用手机上的后退按钮退出应用程序时,有时会导致手机崩溃。它实际上并没有关闭它,而是再次运行启动动画 这是我从logcat得到的一个例外,这个片段重复了很多次。该应用程序是一个测验,因此只依赖于数据库 任何关于如何解决这一问题的建议都将不胜感激 11-20 15:47:40.236: DEBUG/WifiStateTracker(1505): get mPhoneStateListener 11-20 15:47:41.087: DEBUG/SensorServ

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

这是我从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->B

如果我经过这个过程,回答了大约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();
}

在活动C中,去掉
startActivity
。您只需要
setResult(int,intent)
。当我们进行此操作时,请将变量名更改为小写
intent
。引用类型时仅使用大写的
Intent


另外,如果你在获得结果时简单地
完成
活动
,那么活动B中的
活动结果
有什么意义呢?

在活动C中,去掉
开始活动
。您只需要
setResult(int,intent)
。当我们进行此操作时,请将变量名更改为小写
intent
。引用类型时仅使用大写的
Intent


另外,如果您在获得结果时只需完成
活动
,那么活动B中的
onActivityResult
有什么意义呢?

您是否在应用程序中使用了设备传感器?没有,除非数据库计数您在其他设备上尝试过此操作?另外,您没有重写onBackPressed(),是吗?Max,如果是在特定活动中按下后退按钮,您可以发布该活动的代码吗?另外,子类化应用程序是否在任何地方?只是想弄清楚你的应用程序中发生了什么。如果你能捕获已过滤的logcat输出,只显示system_服务器进程,我们可能会看到设备重新启动的原因。在Eclipse中,您可以通过在Logcat查看器中创建一个“by PID:52”过滤器来实现这一点,或者从命令行使用
adb Logcat | grep“52):“
(其中52是系统服务器PID,在Eclipse的“设备”窗口中可见,或者从
adb shell ps | grep系统服务器
).您是否正在使用应用程序中的设备传感器?没有,除非您在其他设备上尝试过此操作,否则根本不会使用?另外,您没有重写onBackPressed(),是吗?Max,如果是在特定活动中按下后退按钮,您可以发布该活动的代码吗?另外,子类化应用程序是否在任何地方?只是想弄清楚你的应用程序中发生了什么。如果你能捕获已过滤的logcat输出,只显示system_服务器进程,我们可能会看到设备重新启动的原因。在Eclipse中,您可以通过在Logcat查看器中创建一个“by PID:52”过滤器来实现这一点,或者从命令行使用
adb Logcat | grep“52:”
(其中52是系统服务器PID,在Eclipse的“设备”窗口中可见,或者从
adb shell ps | grep system_server
)来实现。您的意思是摆脱startActivity吗?谢谢您的帮助。这真的让我很高兴,我可以让它工作。听了你的建议后,我看了一眼,实际上做了你的第二个建议。你是说摆脱startActivity?谢谢你的帮助。这真的让我很高兴,我可以让它工作。听了你的建议后,我看了一眼,实际上做了你的第二个建议。工作很愉快。