본문 바로가기

분류 전체보기

Android: Intent 활용 사례 안드로이드 Intent에서 앱을 호출하는 방법을 정리 합니다. 연락처 Intent 연락처 조회 intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://contacts/people/" + String.valueOf(contact.getId()))); startActivity(intent); 연락처 등록 intent = new Intent(Intent.ACTION_INSERT, Uri.parse("content://contacts/people")); startActivity(intent); 연락처 수정 intent = new Intent(Intent.ACTION_EDIT, Uri.parse("content://contacts/people/" + Strin.. 더보기
안드로이드 표준코딩스타일 가이드 20개 정도 규칙이 있으며 출처는 source.android.com에서 좀 더 자세한 내용을 볼 수 있다. build된 sdk에는 없지만 sdk 소스를 다운받으면 이클립스용 코딩 포맷과 import순서가 정보가 적힌 xml파일도 같이 받을 수 있는데, 이 글에 첨부했다. android-formatting.xml은 "Window › Preferences › Java › Code Style > Formatter 에 import하고, android.importorder "Organize Imports에 import하면 Shift+command+F로 자동포멧정리 기능을 안드로이드에 맞게 사용할 수 있다. Java Language Rules Exceptions: 예외 무시하지말고 처리하기. Exceptions: .. 더보기
파일명으로 리소스 가져오기 Bitmap testImg = BitmapFactory.decodeResource(res, R.drawable.testRes0); 이런식으로 파일 ID로 리소스를 읽어와 사용하고 있었습니다. 그런데 리소스가 많을 경우 testImg = new Bitmap[10]; for(int i = 0; i < 10; i++) testImg[i] = BitmapFactory.decodeResource(res, R.drawable.testRes0+i); 이런식으로 ID로 연산을 하여 읽어오다보면 ID가 꼬이는 경우 문제가 발생할 여지가 많더군요. 파일명이 순차적으로 되어 있다고 하더라도 이런식의 접근은 안좋은 방법인것으로 알고 있습니다. 이럴경우 int tmpID; testImg = new Bitmap[10]; for(.. 더보기
구글 음성검색을 텍스트화 시키기 public class Speech extends Activity implements OnClickListener { private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234; private ListView mList; TextView text1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button speakButton = (Button) findViewById(R.id.btn_speak); text1 = (TextView) findViewById(R.id.text.. 더보기
안드로이드 android javascript 연동하기 1. Android에서 Javascript함수 호출하기 webView.loadUrl("javascript:callJS('Hello from Android')"); 다음과 같은 방식으로 javascript:methodname 과 같은 문자열을 넣어 WebView.loadUrl 메소드의 인자로 호출한다. 2. Javascript에서 Android 호출하기 /** Object exposed to JavaScript */ private class AndroidBridge { public void callAndroid(final String arg) { // must be final handler.post(new Runnable() { public void run() { Log.d(TAG, "callAndroid.. 더보기
안드로이드 webview에서 back키를 눌렀을 경우 처리 @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) { webview.goBack(); return true; } return super.onKeyDown(keyCode, event); } 더보기
제11회 한국자바개발자컨퍼런스 오랜만에 좋은 소식이 왔네요. 정보도 얻을 수 있고, 가수 달샤벳도 온다네요^^ 고고싱 합시다. ㅋㅋ 더보기
디자이어 에서adb가 설치 되지 않는 현상 디자이어 폰에서 adb가 설치 되지 않는 현상이 나타났다. ANDROIDUSB.sys 파일과 wdfcolnstaller01007.dll 파일이 있음에도 불구하고 adb 설치중에 위와 같은 파일이 필요하다고 나온다. 구글링과 네박사에게 물어봐서 해봐서 해결되지 않아 혹시 c드라이브가 락 걸려 있는것이 아닌 가 싶어서 확인 결과 일반 폴더 수정도 되지 않는 것을 확인 할 수 있었다. 삭제와 생성은 되는.. "다른 사람이나 다른 프로그램에서 사용하고 있습니다." 라면서 수정이 되지 않는다. 그래서 해결방법으로 언락프로그램을 사용하여 c드라이브를 푸니 바로 해결 완성! 이 삽질로 하루가 갔구나.. ㅠㅠ 이와 같은 삽질을 또 하지 않기를 바라면서.. 더보기
빈공간 줄이기. // for(int x=0; x< obList.size(); x++){ // String str = obList.get(x); // String[] strArray = str.split(" "); // strArray[strArray.length-1] = strArray[strArray.length-1].trim(); // // // str = ""; // for(int j = 0; j < strArray.length-1; j++){ // str += strArray[j]+" "; // } // // str = strArray[strArray.length-1]; // obList.set(x, str); 더보기
자동 동기화 상태 체크 (1.6 버전) Method getContentService = ContentResolver.class.getMethod("getContentService"); mContentService = getContentService.invoke(null); mGetListenForNetworkTickles = mContentService.getClass().getMethod("getListenForNetworkTickles"); 실제 getListenForNetworkTickles () api를 사용 할 경우 경로를 잡지 못해 상태체크를 못해 방황하고 있었는데 실제 위의 방식으로 폰으로 포팅하여 돌려봤을때 제대로 동작하는 것을 볼 수 있다. 더보기