본문 바로가기

android

[Android] WebView File Upload input 태그를 이용하여 파일 업로드를 할 때, Chrome Browser에서는 잘 되지만,앱 WebView에서는 동작을 하지 않는다. 결국 구글링과 Chrome 소스를 참고 해서 File Upload를 테스트 해 보았다. 내가 테스트한 WebView 셋팅 소스 이다.가장 중요한 부분이 setWebChromeClient 함수 이다. private static final String TYPE_IMAGE = "image/*"; private static final int INPUT_FILE_REQUEST_CODE = 1; private ValueCallback mUploadMessage; private ValueCallback mFilePathCallback; private String mCameraPho.. 더보기
[Android] 내가 자주 쓰는 adb 명령어 1. 스키마 테스트 실행 adb shell am start -a android.intent.action.VIEW -d scheme://host 2. 도즈 모드 테스트 - Android M 버전 이상 - 배터리 충전 방지 adb shell dumpsys battery unplug - 도즈 모드 변경 adb shell dumpsys deviceidle step ## 참고 출처 : http://www.dreamy.pe.kr/zbxe/CodeClip/163972 [Usage]- am start -a android.intent.action.MAIN -n 패키지명/액티비티 경로명- am startservice -n 패키지명/서비스경로명- adb shell am broadcast -a "브로드캐스트명" 쉘에서 액티비.. 더보기
[Android] Scheme 설정 시, 앱이 안보이는 현상 scheme를 통하여 앱을 실행하고자 할 때, AndroidManifest에 지정을 해주는 데요.갑자기 앱 아이콘이 보이지 않는 현상이 발생합니다. 이럴땐 당황하지 말고 혹시 아래와 같이 쓰시지 않았나요? 위와 같이 intent-filter에 MAIN과 VIEW를 같이 겹쳐 놓으시면VIEW로 인식이 되어 앱이 설치는 되었지만 아이콘이 보이지 않는 거죠. 그래서 아래와 같이 따로 지정하시면 됩니다. 참고하세요. 더보기
[Android ] WebView addJavascriptInterface 사용시 유의점. 개발 중인 앱이 API 17 미만 버전을 지원한 상태에서 addJavascriptInterface를 사용할 경우, 아래와 같은 설명이 나옵니다. WebView.addJavascriptInterface should not be called with minSdkVersion < 17 for security reasons: JavaScript can use reflection to manipulate application less... (Ctrl+F1) For applications built for API levels below 17, WebView#addJavascriptInterface presents a security hazard as JavaScript on the target web page ha.. 더보기
[Android] WebView에서 Javascript Alert 창이 보이지 않을 때 아래는 제가 WebView를 셋팅하는 소스 입니다. // Enable pinch to zoom without the zoom buttons mWebView.getSettings().setBuiltInZoomControls(true); // Enable pinch to zoom without the zoom buttons if(Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { // Hide the zoom controls for HONEYCOMB+ mWebView.getSettings().setDisplayZoomControls(false); } if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SAN.. 더보기
[Android] ConnectivityManager getNetworkInfo(int) deprecated 아래와 같은 소스를 이용하여 네트워크가 Wifi/Mobile 인지 체크를 하였습니다. 네트워크 상태도 체크를 하였구요. public static boolean isWifiConnected(Context context) { ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (ni != null && ni.isAvailable() && ni.isConnected()) return true; else return false; } public static b.. 더보기
[Android] AlarmManager를 이용한 Schedule 관리 우선, 미리 말씀을 드리겠습니다. 제가 테스트 해 본 결과, AlarmManager는 최소 5초 이상은 지정을 해야 합니다.구글 에서는 10초 이상을 권장 하더라구요.1초마다 지정을 할 경우는 5초마다 불러오게 됩니다. 그리고 도즈 모드에서는 적어도 10분 걸릴 수도 있다고 합니다. 그럼 만들어본 로직은 AlarmManager를 Repeat를 쓰지 않고 아래 형태로 호출하도록 하였습니다. private void startAlram(Context context, PendingIntent pendingIntent, int delay) { // AlarmManager 호출 AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_.. 더보기
[Android] 이미지 크기 알아보는 방법 /** Get Bitmap's Width **/ public static int getBitmapOfWidth( String fileName ){ try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(fileName, options); return options.outWidth; } catch(Exception e) { return 0; } } /** Get Bitmap's height **/ public static int getBitmapOfHeight( String fileName ){ try { BitmapFactory.Opt.. 더보기