Skip to content

Instantly share code, notes, and snippets.

@acidsound
Created October 25, 2011 16:57
Show Gist options
  • Save acidsound/1313481 to your computer and use it in GitHub Desktop.
Save acidsound/1313481 to your computer and use it in GitHub Desktop.
Android Web App 만들때 고려할 것들
Android Web App 만들때 고려할 것
- 최종 단계에서 <application android:debuggable="false"> 디버그 기능 무효화
- 회전시 화면 갱신 문제
activity 에 android:configChanges="keyboardHidden|orientation" 추가
- 화면 확대 축소 금지 : <m-ta name="viewport" content="user-scalable=no, width=device-width" />
- 기기해상도별 스타일 시트 적용
<link rel="stylesheet" type="text/css" href="wvga.css" media="screen and (min-width: 480px)" />
<link rel="stylesheet" type="text/css" href="qvga.css" media="screen and (min-width: 320px)" />
- webkit 으로 시작하는 css를 적극적으로 사용
-webkit-border-top-left-radius: 8px;
-webkit-gradient(linear, left top, left bottm, from(#ccc), to(#999));
-webkit-border-image: url(corner.png) 0 8 0 8;
- webkit-tap-highlight-color 를 사용하여 탭할때 포커싱이 될때 테두리가 생기지 않도록
-webkit-tap-hight-color: rgba(0,0,0,0);
- 데이터 저장이 필요할 땐 webStorage의 사용.
localStorage 객체 - 단순히 localStorage.variable = "value"; 식으로 넣고 빼면 되는 K/V 구조
sessionStorage, sessionStorage.currentDate
- webSQL 고려
openDatabase([shortName], [version], [displayName], [maxSize:int]);
ex) db = openDatabase ('Kilo', '1.0', 'KiloStorage', 65536);
db.transaction(
function(transaction) {
transaction.executeSql( "CREATE TABLE IF NOT EXISTS entries (id INTEGER, .....",
[arguments1, ..2, ....], -- ? 형태 placeholder 사용시 --
function(transaction, result) { -- callback -- }, -- select 일때는 인자 필요, CUD는 상관 없음, 필요없으면 null로 대치 --
function(transaction, error) { -- error handler -- return true; } -- true면 오류, false면 오류아님 --
);
}
);
result 객체는 result.rows.length, result.rows.item(n) 을 가지고 있고 result.rows.item(n).[field명] 과 같이 사용
- gradient 와 text-shadow 는 한쌍으로 사용
- jQuery.load 를 사용한 preload 및 hijacking- 저장장소 문제 : android:installLocation="preferExternal" 이 좋긴함. 외장 메모리 우선
- 타이틀바 가리기 : android:theme="@android:style/Theme.NoTitleBar"
- 백버튼 종료하기
- 백/홈버튼을 눌러 어플리케이션을 빠져나갈때 Background로
flash가 계속 동작하는 현상을 방지하기 위해 reflect를 사용 onPause 처리를 한다.
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
callHiddenWebViewMethod("onResume");
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
callHiddenWebViewMethod("onPause");
}
private void callHiddenWebViewMethod(String name){
if( mWebView != null ){
try {
Method method = WebView.class.getMethod(name);
method.invoke(mWebView);
} catch (NoSuchMethodException e) {
Log.e("No such method: " + name , e.toString());
} catch (IllegalAccessException e) {
Log.e("Illegal Access: " + name, e.toString());
} catch (InvocationTargetException e) {
Log.e("Invocation Target Exception: " + name, e.toString());
}
}
}
- 로딩시 처리 : onProgressChanged
- 커스텀 프로토콜인 전화연결(tel:) : shouldOverrideUrlLoading 에서 처리 (iOS는 따로 안해도 되던가?)
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
startActivity(intent);
} else if (url.startsWith("http:") || url.startsWith("https:")) {
view.loadUrl(url);
}
return true;
}
- 비밀번호 저장 여부를 묻지 않도록
- 플래쉬일 경우
- 슬립모드에서 돌아오거나 Orientation 이 바뀔때 화면 갱신으로 다시 페이지가 로드되는 현상
- width, height 100%인 embed 가 있을때 우측 하얀색 줄이 생기는 현상. 스크롤인가?
- 웹앱의 좋은 예 : facebook
빠진 부분 잘못된 부분 태클 완전 환영요.
* 10/11일 내용추가
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment