package com.basic.security.activity; import android.content.Intent; import android.view.WindowManager; import android.widget.LinearLayout; import com.alfeye.readcardlib.readcard.ReadCardUtil; import com.basic.security.R; import com.basic.security.activity.helper.MaLoggedInTimeoutToLogout; import com.basic.security.manager.IdCardManager; import com.basic.security.utils.Constants; import com.basic.security.utils.KeyboardUtil; import com.basic.security.utils.PermissionHelper; import com.basic.security.utils.ToastUtil; import com.basic.security.manager.impl.erlang.ErlangProcess; import org.androidannotations.annotations.AfterViews; import org.androidannotations.annotations.Click; import org.androidannotations.annotations.EActivity; import org.androidannotations.annotations.ViewById; import static com.basic.security.utils.Constants.isNewIDCardReader; @EActivity(R.layout.activity_main) public class MainActivity extends MaLoggedInTimeoutToLogout { public MainActivity getActivity() { return this; } public boolean mainActivityInitComplete = false; public static boolean faceDbInitComplete = false; //1是usb模式 0是串口模式 5.1.1 // public ReadUtil readUtil; //新的pad 白色 身份证读卡器 public ReadCardUtil readCardUtil; @AfterViews protected void afterViews() { if (!PermissionHelper.hasWriteStoragePermission(this)) { PermissionHelper.requestWriteStoragePermission(this); } getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // 保持屏幕常亮 hideSystemUIThread(); addFragments(); addCameraToFragment(); addVideoViewToFragment(); addToolbarButtonsToFragment(); addTimeoutToBlank(); addIdCardPhoneComponent(); addBackgroundAndBorderComponent(); addCameras(); setUpClickHook(); addFaceComponents(); addSystemSettingTabs(); addSystemSettingHintTabs(); addPersonManagerComponents(); logoutChecker(); hideOneFragment(fragment_menu); hideOneFragment(fragment_person_identity); hideOneFragment(fragment_face_list); hideOneFragment(fragment_face_detail); hideOneFragment(fragment_system_setting_tabs); hideOneFragment(fragment_su_auto_ic_wait_phone); hideOneFragment(fragment_su_logged_ic_wait_idcard); hideOneFragment(fragment_su_logged_ic_compare_success); hideOneFragment(fragment_background_and_border); showFragment(fragment_home); mainActivityInitComplete = true; checkDeviceId(); } @ViewById LinearLayout id111; @Override protected void onResume() { super.onResume(); Intent intent1 = new Intent(); intent1.setPackage("com.basic.project.idcardservice"); intent1.setAction("com.basic.read.IDCard"); intent1.putExtra("type", "start_service"); intent1.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); startService(intent1); } long startTime = 0; @Override public void onBackPressed() { long currentTime = System.currentTimeMillis(); if ((currentTime - startTime) >= 2000) { ToastUtil.show("再按一次退出"); startTime = currentTime; } else { // ErlangProcess.stopErlangProcess(); exitApp(); } } private void exitApp() { if (isNewIDCardReader) { if (readCardUtil != null) { readCardUtil.stopReadCard(); readCardUtil.destroy(); } } else { IdCardManager.unRegisterBroadcast(this); } finish(); System.exit(0); } @Override protected void onPause() { super.onPause(); KeyboardUtil.hideSoftKeyboard(); } @Override protected void onStop() { super.onStop(); // exitApp(); } }