我尝试自己解决问题并在互联网帮助下解决问题,但仍然无法解决。
我有一个应用程序,它每隔5秒就向用户显示一次信息(如果有的话)。
当我在“最近的应用程序”中强行杀死我的应用程序时,它通常会停止并且服务会重置。该服务寻找要显示的任何新信息。它确定应用程序是否正在运行,如果没有,则显示通知。
当我使用通知启动我的应用程序,然后在“最近使用的应用程序”中强行杀死我时,我的服务将停止并且不会重新启动。
我在Logcat中遇到了以下错误:
2018-12-23 04:16:19.034 1875-2464/system_process I/ActivityManager: Killing 17805:com.example.tomek.securego/u0a97 (adj 900): remove task
2018-12-23 04:16:19.035 1875-1893/system_process W/libprocessgroup: kill(-17805, 9) failed: No such process
2018-12-23 04:16:19.064 1875-1968/system_process W/InputDispatcher: channel 'd9d87a6 com.example.tomek.securego/com.example.tomek.securego.activity_AppAuth (server)' ~ Consumer closed input channel or an error occurred. events=0x9
2018-12-23 04:16:19.065 1875-1968/system_process E/InputDispatcher: channel 'd9d87a6 com.example.tomek.securego/com.example.tomek.securego.activity_AppAuth (server)' ~ Channel is unrecoverably broken and will be disposed!
2018-12-23 04:16:19.066 1875-2792/system_process I/WindowManager: WIN DEATH: Window{d9d87a6 u0 com.example.tomek.securego/com.example.tomek.securego.activity_AppAuth}
2018-12-23 04:16:19.067 1875-2792/system_process W/InputDispatcher: Attempted to unregister already unregistered input channel 'd9d87a6 com.example.tomek.securego/com.example.tomek.securego.activity_AppAuth (server)'
当我通过通知水龙头启动我的应用程序时,这总是会发生。
activity_AppAuth的代码:
public class activity_AppAuth extends AppCompatActivity {
private static final int REQUEST_CODE_ENABLE = 11;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_appauth);
// -- Continue -- //
final String appID = getIntent().getStringExtra("appID");
final String appName = getIntent().getStringExtra("appName");
final String operation = getIntent().getStringExtra("operation");
TextView textView_Application = findViewById(R.id.textView_Application);
TextView textView_Header = findViewById(R.id.textView_Header);
if (operation.equals("add")) {
textView_Header.setText(getString(R.string.text_AddApp_Header_Add));
}
else if (operation.equals("authorization")) {
textView_Header.setText(getString(R.string.text_AddApp_Header_Auth));
}
textView_Application.setText(appName);
Button button_Authorize = findViewById(R.id.button_Authorize);
LockManager<activity_AppAuth_Handler> lockManager = LockManager.getInstance();
lockManager.enableAppLock(activity_AppAuth.this, activity_AppAuth_Handler.class);
button_Authorize.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (LockManager.getInstance().getAppLock().isPasscodeSet()) {
class_SaveSharedPreference.setAddAppResponse(activity_AppAuth.this, "");
Intent activity_AddApp_Handler = new Intent(activity_AppAuth.this, activity_AppAuth_Handler.class);
activity_AddApp_Handler.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity_AddApp_Handler.putExtra("appID", appID);
activity_AddApp_Handler.putExtra("appName", appName);
activity_AddApp_Handler.putExtra("operation", operation);
startActivityForResult(activity_AddApp_Handler, REQUEST_CODE_ENABLE);
}
}
});
}
@Override
public void onDestroy() {
super.onDestroy();
}
}
我不确定这是哪里出了问题,如何避免此错误...求您帮忙。
圣诞快乐:)!