@Override public void onClick(View v) { switch (v.getId()) { case R.id.callOk: edit.putInt(Properties.PREF_CALL_ON_LENGTH_VALUE, onProgress); edit.putInt(Properties.PREF_CALL_OFF_LENGTH_VALUE, offProgress); edit.commit(); this.dismiss(); break; case R.id.callCancel: this.dismiss(); break; case R.id.callTest: if (isEnable) { utils.flickFlash(500, 500); isEnable = false; } else { utils.setFlashEnable(false); isEnable = true; } break; default: break; } }
@Override public void onReceive(Context context, Intent intent) { if (!intent.getAction().equals("android.intent.action.PHONE_STATE")) { return; } // TODO check sharepreferences commonUtils = new CommonUtils(); if (!commonUtils.checkSetup(context.getApplicationContext(), Properties.TYPE_CALL)) { Log.e("han.hanh", "PhoneReceiver: return"); return; } context.startService( new Intent(context, com.example.flashalert.service.CallService.class) .setAction(intent.getAction()) .putExtra( TelephonyManager.EXTRA_INCOMING_NUMBER, intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER)) .putExtra( TelephonyManager.EXTRA_STATE, intent.getStringExtra(TelephonyManager.EXTRA_STATE))); }