본문 바로가기

Android45

액티비티 life cycle [Android] 안드로이드도 다른 프로세스와 마찬가지로 태어나고 죽기까지의 생명주기(life cycle)가 존재합니다. 위 다이어그램은 액티비티가 생성되고 죽기까지의 과정을 순서적으로 나타낸것입니다. 우선 액티비티에 대해 설명하자면, 액티비티는 단말 화면상으로 보이는 뷰(View) 즉 화면을 뜻합니다.액티비티 위에는 다른 뷰들이 올라가게 되고, 그런 뷰들로 화면이 구성됩니다. 즉 액티비티는 도화지, 뷰(버튼,텍스트 등)는그림이라고 생각하시면 이해하기 편합니다. 위 그림을 해석해 보면 onCreate - 액티비티가 시작되면 제일 먼저 onCreate()가 호출됩니다.이 영역에서 어플이 켜짐과 동시에 실행되어야 하는 작업들을 실행하게 됩니다.어플 최초 실행시의 로딩화면 등을 예로 들 수 있겠습니다. onStart() - o.. 2015. 12. 15.
캐시 삭제 캐시 삭제하기 여러가지 내장 컴포넌트들을 사용하다보면 예상하지 못한 캐시가 많이 생성됩니다. 저는 웹뷰를 주로 많이 쓰는데요~ 쓰다보면 내장메모리에 몇메가까지 캐시가 생기더라고요~ webview.clearChache 메써드를 수시로 사용해도 완전히 지워지지 않습니다. 종료시점이나 사용자 메뉴에 아래처럼 쓰시면 바로 0으로 줄어드네요^^ private void clearApplicationCache(java.io.File dir){ if(dir==null) dir = getCacheDir(); else; if(dir==null) return; else; java.io.File[] children = dir.listFiles(); try{ for(int i=0;i 2015. 12. 15.
http request First of all, request a permission to access network, add following to your manifest:Then the easiest way is to use Apache http client bundled with Android: HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = httpclient.execute(new HttpGet(URL)); StatusLine statusLine = response.getStatusLine(); if(statusLine.getStatusCode() == HttpStatus.SC_OK){ ByteArrayOutputStream out = .. 2015. 12. 15.
http post get 전송 1.Get 방식 example) { ... String result = sendData("http://xxx.xxx.xxx/xxx.asp?title=leeminjung&type=article"); ... } private static String sendData(String addr){ StringBuilder html = new StringBuilder(); try{ URL url = new URL(addr); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); if(conn != null){ conn.setConnectTimeout(10000); conn.setUseCaches(false); if(conn.getResponseCode(.. 2015. 12. 15.