본문 바로가기

안드로이드 스튜디오59

코틀린 안드로이드 핸드폰번호 국가코드로 변환시키기 fun phoneNumber82(msg : String) : String{ val firstNumber : String = msg.substring(0,3) var phoneEdit = msg.substring(3) when(firstNumber){ "010" -> phoneEdit = "+8210$phoneEdit" "011" -> phoneEdit = "+8211$phoneEdit" "016" -> phoneEdit = "+8216$phoneEdit" "017" -> phoneEdit = "+8217$phoneEdit" "018" -> phoneEdit = "+8218$phoneEdit" "019" -> phoneEdit = "+8219$phoneEdit" "106" -> phoneEdit = "+8.. 2022. 2. 4.
코틀린 안드로이드 핸드폰번호 패턴체크 fun isPhoneNumberCheck(cellphoneNumber : String) : Boolean { var returnValue = false; val regex = "^\\s*(010|011|012|013|014|015|016|017|018|019)(-|\\)|\\s)*(\\d{3,4})(-|\\s)*(\\d{4})\\s*$"; val p = Pattern.compile(regex); val m = p.matcher(cellphoneNumber); if (m.matches()) { returnValue = true; } return returnValue; } 사용 가능하면 true 그렇지 않으면 false를 반환합니다. 2022. 2. 3.
Android 앱 캐시 및 데이터 내가 원하는것만 골라서 삭제해보자. public static void clearApplicationData(Context context) { File cache = context.getCacheDir(); File appDir = new File(cache.getParent()); if (appDir.exists()) { String[] children = appDir.list(); for (String list : children) { Log.d("캐시삭제 ", list); if(list.equals("shared_prefs")) continue; deleteDir(new File(appDir, list)); } } } private static boolean deleteDir(File dir) { if (dir != null && di.. 2021. 8. 20.
안드로이드 AppCompatActivity 상속 관련 에러 import androidx.appcompat.app.AppCompatActivity; 해당 import가 이뤄지지 않아 에러가 나는 경우가 있습니다. (엥!? 어제까지 잘 되던건데 왜 이게? 그냥 프로젝트만들면 되어있는건데..) 이런식으로 import가 안되서 상속이 이뤄지지않아 밑에 줄줄이 에러가 발생합니다.. 이럴때는 build.gradle (:app) 해당부분으로 가보시면 dependencies에 각종 의존성을 추가합니다. 그쪽에 보시면 implementation 'androidx.appcompat:appcompat:1.1.0' 이런게 있는데요 지금 버전이 1.1.0으로 저는 되어있습니다. 이걸 그냥 1.1.1로 바꾸고 (다른 수여도 좋아요) 오른쪽 위에 Sync Now 눌러줍니다. 그리고 다시 .. 2021. 3. 26.