【发布时间】:2012-08-07 03:46:03
【问题描述】:
我试图在服务运行时阻止 HOME 按钮 KeyPress
protected void onPause () {
if (isMyServiceRunning())
{
Intent Act2Intent = new Intent(PhysicalTheftDialog.this, PhysicalTheftDialog.class);
startActivity(Act2Intent);
}
else {
}
}
private boolean isMyServiceRunning() {
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if ("nyp.android.project.MyService".equals(service.service.getClassName())) {
return true;
}
}
return false;
}
但是每次我按下我的主页按钮时,应用程序都会崩溃。
【问题讨论】:
-
您能否发布 LOGCAT 崩溃时的输出?
标签: android android-service android-homebutton