profile image

L o a d i n g . . .

반응형

안드로이드 개인 세미 프로젝트

Android Personal Semi Project


완벽한 고급기능은 구현하지 못하였지만 기본적인 기능은 1개 빼고 모두 구현한 상태이다.
지금 현재 스탑워치 기능은 물론 설정에서 배경화면 선택과 대기화면은 구현한 상태이다.
이제 남은건 기록인데 이는 어찌해야 하는지 또 자료를 찾아보아야 겠다.

I haven't implemented the perfect advanced function, but the basic functions are all implemented except one
Now i have implements STopWatch function, SettingView that select background and wating view
Now what's left is the record, and i'm going to have to look up the google

// 잠금화면으로 이동
// Go to the LockView
lock_Id.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, LockActivity.class);
startActivity(intent);
}
});

대기화면 혹은 잠금화면으로의 뷰 이동은 Intent를 사용하여 간단하게 넘겼다.


movement of WaitView or LockView is simply trurned it over using an Intent


@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lock);

Log.d(TAG, "lock check");
lock_Button = (Button) findViewById(R.id.lock_Button);

/*HomeKeyLocker homeKeyLocker = new HomeKeyLocker();
homeKeyLocker.lock(this);*/

/*getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);*/

// 해제버튼 -> 메인 액티비티로 이동
// button -> MainActivity
/*lock_Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});*/


lock_Button.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {

int action = event.getAction();

switch (action) {
case MotionEvent.ACTION_DOWN:
time_down = System.currentTimeMillis();
break;
case MotionEvent.ACTION_UP:
time_up = System.currentTimeMillis();
if (time_up - time_down > 2000) {
finish();
}
break;
}
return false;
}
});

}

많은 시도를 해보았지만 모두 실패하여 구현하지 못하였다.

홈키와 백키를 막아주는 코드가 있어서 사용해 보았지만 권한문제로 실패하였다.

결국 마지막에 내가 생각해둔 잠금해제 방법인 키를 2초이상 누르고 있어야 풀리는 기능은 구글을 통하여 응용하여 구현하였다.

OnTouchListener을 이용하여 구현하였지만, 나중에 알았지만 OnLongClickListener을 쓰면 더 간단하게 구현할 수 있다는 것을 알았다.


Many attempts have been made, but none have been implemented because they have failed.

I tried it because there was a code that prevented the home key and the back key, but failed due to problem of authority

In the end, the function that unclocks the key taht i thought was needed for more than 2 seconds was implemented through Google.

OnTouchListener was implemented using this, but later it was known that OnTouchListener made it simplely to implement


 if(savedInstanceState != null) {
State_Time = savedInstanceState.getString(State_Time);
} else {
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
savedInstanceState.putString(State_Time, getTime());

super.onSaveInstanceState(savedInstanceState);

잠금화면으로 왔다가 다시 돌아오면 스탑워치가 초기화 되는 문제가 보여서 

또 구글에 검색하면서 찾아보아서 해결했다고 생각했지만,

결국 지금 나의 프로젝트 상황과 수준을 생각해 볼때 finish()만 넣어도 충분히 된다는 결과를 알 수 있었다.

위에 코드는 되는지 안되는지 확인하지 못하였다.


When come back to the lock screen, i see the problem of resetting the StopWatch

I tried to using Google and i thought soulution

After all. considering my project situation and level, i could see that just putting in the finish(); is enough

The above code could not be verified.





I want to be happy


반응형
복사했습니다!