Android [Unable to add window, token null is not valid. is your activity running?]

Posted Leave a commentPosted in 안드로이드

AlertDialog 를 생성할 때 getApplicationContext()를 사용하면 에러가 납니다. 이때는[Activity이름].this 로 변경하면 해결됩니다. 다음은 예시입니다. AlertDialog.Builder b = new AlertDialog.Builder(ConfigDeviceTypeChoiceActivity.this); b.setTitle(“등록 성공”); b.setMessage(“성공적으로 등록하였습니다.”); final AlertDialog alert = b.create(); alert.show();

안드로이드 Thread(스레드) JOIN 사용법

Posted Leave a commentPosted in 안드로이드

쓰레드의 Join() 을 이용하면 쓰레드 가 끝날때까지 쓰레드를  호출한 메소드는 대기 하게 됩니다. Join을 이용해 쓰레드를 순차적으로 구동시킬 수 있습니다. Thread t1 = new Thread(new EventThread(“e1”)); t1.start(); Thread t2 = new Thread(new EventThread(“e2”)); t2.start(); while (true) { try { t1.join(); t2.join(); break; } catch (InterruptedException e) { e.printStackTrace(); } } 그런데, 쓰레드 내에서 콜백 함수의 […]

안드로이드 스튜디오 Missing Constraints in ConstraintLayout 에러 해결 방법

Posted Leave a commentPosted in 안드로이드

Missing Constranints in ConstraintLayout This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints The layout editor allows you to place widgets anywhere on the canvas, and it records the current position with designtime attributes (such as layout_editor_absoluteX). These attributes are not […]