본문 바로가기

프로그래밍/Android-Java34

[ANDROID] Library AAR 파일 생성 aar 만드는 방법은 생각보다 간단했다.! 1. MainActivity 삭제 지워도 상관 없을 것 같으나 나는 그냥 지워줬다 여기서 AndroidManifest.xml도 수정해줘야 한다. 2. Plugins ID 수정 //기존 코드 plugins { id 'com.android.application' } //아래와 같이 수정 plugins { id 'com.android.library' } 3. defaultConfig applicationId 제거 defaultConfig { // applicationId "com.test.testaar" minSdkVersion 16 targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunn.. 2021. 9. 29.
[ANDROID] failed to apply plugin 'com.github.dcendents.android-maven'. git에 있는 오픈 소스를 가져와 빌드를 하려 하니 아래와 같은 에러가 나며 빌드가 실패했다. > Failed to apply plugin [id 'com.github.dcendents.android-maven'] > Could not create plugin of type 'AndroidMavenPlugin'. > Unable to determine constructor argument #1: missing parameter of type Factory, or no service of type Factory. 해결 방법 해당 프로젝트 build.gradle에는 다음과 같이 되어있었다. buildscript { repositories { jcenter() google() } dependencies { c.. 2021. 9. 15.
[ANDROID] Activity View 구하기 1. id를 이용하여 구하기 setContentView(R.layout.activity_main,null); View view = findViewById(R.id.layout); 2. View 객체에 담기 View view = getLayoutInflater().from(this).inflate(R.layout.activity_main,null); setContentView(view); 2021. 2. 18.
[ANDROID] byte array rotate 앱을 landscape로 실행시켰더니 카메라도 같이 돌아가버렸다... camera.setDisplayOrientation(90); 위와 같이 설정을 해도 보이는 화면만 돌아가있지 막상 bitmap을 찍어서 보면 적용이 안되어있어서 골머리를 썩히다가 방법을 찾았다 ! 카메라 onPreviewFrame에서 들어오는 byte array 데이터를 돌리면 된다 ! public static byte[] rotateNV21(byte[] input, int width, int height, int rotation) { byte[] output = new byte[input.length]; try { if (rotation == 0) { System.arraycopy(input, 0, output, 0, input.le.. 2021. 1. 27.
[ANDROID] react-native 설치 & 프로젝트 생성 cmd 창을 열어서 nodeJS가 설치되어있는지 확인해보기. 설치가 되어있지 않다면 따로 설치하고 시작하기 바람 >node --version v12.16.2 다음과 같이 [ npm install -g react-native-cli ] 명령어를 실행해준다. -g : global. 전역 범위에서 설치, 사용 하겠다는 의미 >npm install -g react-native-cli ...\AppData\Roaming\npm\react-native -> ...\AppData\Roaming\npm\node_modules\react-native-cli\i ndex.js + react-native-cli@2.0.1 added 79 packages from 28 contributors in 3.189s npm으로 설치.. 2021. 1. 18.
[ANDROID] onKeyDown KeyEvent 변경 작업을 하다가 화면을 90도 회전해서 처리해야하는 작업들이 생겼다. 리모콘에서 상하좌우 key event도 90도 회전시킨 evnet로 처리해야 하는데 방법을 몰라 몇시간을 헤맸다. public boolean onKeyDown(final int keyCode, final KeyEvent event) 에서 다음과 같이 처리를 해줬다. if(keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { new Thread(new Runnable() { @Override public void run() { try { inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_UP); } catch (Exception e) {} } }).start(); return true; }.. 2021. 1. 15.
[ANDROID] StringBuffer 비우기 StringBuffer를 사용하던 중, 버퍼를 비우고 새로 쓰고 싶어서 방법을 찾아보았다. 1. null 값을 넣고 새로 객체 생성하기 StringBuffer strbuffer = new StringBuffer(); strbuffer.append("test"); strbuffer = null; strbuffer = new StringBuffer("test2"); 2. length를 0으로 초기화하기 StringBuffer strbuffer = new StringBuffer(); strbuffer.append("test"); strbuffer.setLength(0); strbuffer.append("test2"); 2020. 12. 16.
[ANDROID] byte array 초기화 byte array를 초기화 하는 방법을 찾아보았다. Arrays.fill(buffer, (byte)0); byte 배열에 데이터를 쓰고, 초기화를 안해주고 다시 그 배열에 데이터를 쓰니까 그 전에 있던 내용이 지워지지 않고 남아있었다. 위의 코드로 초기화를 해주니 해결됨 ! 2020. 12. 16.
[ANDROID] java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 앱을 실행하던 도중 다음과 같은 에러가 떴다. E AndroidRuntime: FATAL EXCEPTION: Thread-2656 E AndroidRuntime: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() E AndroidRuntime: at android.os.Handler.(Handler.java:204) E AndroidRuntime: at android.os.Handler.(Handler.java:118) E AndroidRuntime: at android.app.Dialog.(Dialog.java:123) E AndroidRuntime: at android.ap.. 2020. 12. 15.
[ANDROID] byteArray to String 파일에서 byte array로 글을 읽어와야 하는 부분이 있다. String으로 변환해서 출력을 하고 싶어 방법을 찾아봤더니 생각보다 간단했다. new String(byteArray, StandardCharsets.UTF_8); 위와 같이 String 객체로 변환해주면 된다! 2020. 12. 15.