본문 바로가기

Android

(3)
[Android] 비트맵 이미지 생성, 크롭, 회전 1. 비트맵 이미지 생성 //넓이, 높이 조절로 이미지 크롭 가능 Bitmap.createBitmap([비트맵 객체], [x시작],[y시작], [너비], [높이]) Bitmap.createBitmap(bitmap, 0,0, width, height) 2. 비트맵 이미지 생성 및 크롭 //중앙을 기준으로 크롭 fun cropBitMap(bitmap: Bitmap, cropWidth: Int, cropHeight: Int): Bitmap { //(이미지 넓이 - 크롭 넓이)/ 2 val x = (bitmap.width - cropWidth) / 2 //(이미지 높이 - 높이)/ 2 val y = (bitmap.height - cropHeight) / 2 return Bitmap.createBitmap(bit..
[Android] 비트맵 이미지를 파일로 변환 비트맵 객체를 지정된 경로에 저장하는 방법 public void bitmapToFile(Bitmap bitmap, String filePath) { File file = new File(filePath); FileOutputStream out; try { out = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); } catch (Exception e) { e.printStackTrace(); } } public fun bitmapToFile(bitmap: Bitmap, filePath: String) { val file = FilefilePath val out: FileOutputStream try { o..
[Android] ForegroundServiceDidNotStartInTimeException 이슈 발생 백그라운드에서 지속적으로 서비스를 실행시키기 위한 서비스이며, 사용자가 동작 중인 사실을 상태 표시줄 (노티피케이션 알림)로 출력하는 서비스이다. (결국에는 백그라운드에서 동작하는 서비스라는 얘기인데,, 말을 풀어서 쓰는게 어렵,) ​ ​ 다시 본론으로 돌아와서 ForegroundServiceDidNotStartInTimeException 이슈의 경우,, ​ startForegroundService() API 호출로 포어그라운드 서비스를 실행시키는데,,,, 포어그라운드로 올리려는 서비스 내에서 startForeground()가 5초 이상 호출되지 않으면 발생한다.. 당연히 5초 이내에 실행될 것이라고 생각하고 있었는데 발생하는 경우가 있었다 startForegroundService()를 통해 서비스를 실..