@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_GET_BASIC_INFO) { if (resultCode == RESULT_OK) { dataManager.queryInsert(data, iAgreement); } else { if (dataManager.isExperimentInfoRecorded()) { Intent intentExp = new Intent(this, BasicInfo.class); startActivityForResult(intentExp, REQUEST_GET_BASIC_INFO); } } } else if (requestCode == REQUEST_GET_PERSONAL_INFOMATION_AGREEMENT) { if (resultCode == RESULT_OK) { iAgreement = data.getIntExtra("AgreementType", 0); Intent intentExp = new Intent(this, BasicInfo.class); startActivityForResult(intentExp, REQUEST_GET_BASIC_INFO); } else { if (dataManager.isExperimentInfoRecorded()) { Intent intentExp = new Intent(this, InfoAgreement.class); startActivityForResult(intentExp, REQUEST_GET_PERSONAL_INFOMATION_AGREEMENT); } } } else if (requestCode == REQUEST_SERVICE) { Log.e("Main Activity", "Service End"); // TODO: 2015-12-02 추후 서비스 개발 완료되면 메인 액티비티 종료 코드를 추가할 것 } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); notiMaker = new NotificationGenerator(this); dataManager = DataManager.getManager(this); textInputBox = (EditText) findViewById(R.id.adminPass); textView = (TextView) findViewById(R.id.textView); listView = new ArrayList<>(); listView.add(findViewById(R.id.main_button_execute)); listView.add(findViewById(R.id.main_button_notigen)); listView.add(findViewById(R.id.main_button_readlog)); listView.add(findViewById(R.id.main_button_datadelete)); Button btnComplete = (Button) findViewById(R.id.main_button_complete); listView.add(btnComplete); listView.add(textView); bar = (ProgressBar) findViewById(R.id.main_progressBar); if (dataManager.isExperimentInfoRecorded()) { Intent intentExp = new Intent(this, InfoAgreement.class); startActivityForResult(intentExp, REQUEST_GET_PERSONAL_INFOMATION_AGREEMENT); } if (Build.VERSION.SDK_INT >= 19) { if (!isContainedInNotificationListeners(getApplicationContext())) { Toast.makeText(this, "SocialSpace를 활성화시켜 주세요", Toast.LENGTH_LONG).show(); Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"); startActivityForResult(intent, REQUEST_START_NOTIFICATION_SERVICE); } } else if (Build.VERSION.SDK_INT < 19 && Build.VERSION.SDK_INT >= 16) { Log.e("Main Activity", "Notification Miner run as compat mode"); if (isNotificationMinerCompatStarted()) { Log.e("Main Activity", "Notification Miner Compat Mode was already started."); } else { Toast.makeText(this, "접근성의 SocialSpace를 활성화시켜 주세요", Toast.LENGTH_LONG).show(); Intent intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS); startActivityForResult(intent, REQUEST_START_ACCESSIBILITY_SERVICE); } } else { Log.e("Main Activity", "Current SDK is under 16. This app may not work properly."); Toast.makeText( MainActivity.this, "Warning : This Device is using old Android", Toast.LENGTH_SHORT) .show(); } if (!isCallEventMinerServiceStarted()) { startService(new Intent(this, CallEventMiner.class)); } if (dataManager.querySettingInitialized()) { Log.e("Main Activity", "Relaunched"); } else { Datastone[] call = CallMiner.getMiner().mineAllData(this); for (int i = 0; i < call.length; i++) { dataManager.queryInsert(call[i]); } } Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int date = calendar.get(Calendar.DATE); Log.e("Main Activity", year + "-" + month + "-" + date); if (year >= 2015 && month >= 11 && date >= 6) { btnComplete.setVisibility(View.VISIBLE); } }