본문 바로가기

Android124

코틀린 안드로이드 핸드폰번호 국가코드로 변환시키기 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.
안드로이드 코틀린 SMS(문자) 인증번호 자동입력 BroadcastReceiver 문자로 오는 인증번호를 추출하는 브로드케스트 리시버(BroadcastReceiver) 를 해보겠습니다. 우선 BroadcastReceiver 클래스를 만들어볼게요. 클래스 이름은 SMSReceiver로 지었습니다! 그리고 메니페스트에서 퍼미션 추가해줄게요.! 원래는 RECEIVE_SMS만 있어도 되는데 저는 나중에 뭐 또 쓸 일 있을거같아서 3개 다 넣었습니다.. 그리고 메니페스트에서 리시버를 등록해줘야 합니다. 이렇게 액션도 추가하여 달아줬습니다. class SMSReceiver : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { if(intent?.action.equals("android.provide.. 2022. 1. 19.
안드로이드 코틀린(Kotlin) 멀티파트(Multipart)를 이용하여 웹으로 사진 전송 우선 라이브러리 먼저 추가해줍니다. implementation 'com.squareup.retrofit2:converter-scalars:2.5.0' implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0' implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.squareup.retrofit2:converter-gson:2.1.0' 그리고 레트로핏 기본 셋팅부터 하도록 하겠습니다. import okhttp3.OkHttpClient import retrofit2.Retrofit import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory impo.. 2022. 1. 17.