2026/03/17

오늘의 이야기

Zxing 은 qrcode, barcode 인식을 위해서 공유되는 open source 라이브러리입니다. 

오늘은 이것을 활용해서 QRCode 을 만들어서 앱에 공유 하는 이야기를 해 보고자 합니다.  이전 포스팅을 통해서 barcode 을 생성해 주는 앱을 하나 만들어 playstore에 게시했던 기억이 있습니다. 


 


https://billcorea.tistory.com/324



 


할인쿠폰 모아보기 앱 사용자 가이드


이 앱은... 마트에 갔을 때 제공 되는 각종 할인 쿠폰을 이미지로 담아 두었다가 다음 방문 시에 활용할 수 있도록 지원하는 것을 목적으로 합니다. 화면이 비어 있다면 아직 자료가 1도 없다는


billcorea.tistory.com




이 앱은 바코드 스캔을 하기도 하고 스캔 했던 바코드를 재활용(?) 하기 위해서 화면에 보여 주기도 합니다. 


 


QRCODE 는 

이번에는 QRCODE 을 만들어 내는 구현을 헤 보았습니다. 


 


 


바코드 종류



https://github.com/zxing/zxing#supported-formats



 


GitHub - zxing/zxing: ZXing ("Zebra Crossing") barcode scanning library for Java, Android


ZXing ("Zebra Crossing") barcode scanning library for Java, Android - GitHub - zxing/zxing: ZXing ("Zebra Crossing") barcode scanning library for Java, Android


github.com




해당 라이브러리의 홈페이지에 기술 되어 있는 것처럼 구현 될 수 있는 바코드의 종류가 여러 개 있기는 합니다.  이 것들 중에서 사용해 보았던 것은 Code-128을 이용해서 할인쿠폰 모아보기 앱을 만들어 보았습니다.


 


이번에는 QRCode 을 활용할 예정 입니다.  이전에 개발해서 playstore에 게시한 주문이요 앱등에서 사용됩니다.


 


구현해 보기

 


gradle 설정은 예전에 했던 것과 같이 아래와 같습니다.


 


// barcode scan & make
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
implementation 'com.google.zxing:core:3.4.1'

버전이 달라질 수 있으므로 개발하고자 하는 시점에 라이브러리 홈페이지에서 최종 버전을 확인하고 적용하는 것은 좋을 듯합니다.


 


composable에서 기술되는 코드는 아래처럼 기술이 될 듯합니다. qrUrl이라는 string 값을 그대로 QRCode로 전환해 보여 줍니다.


@Composable
fun QrCodeView (
navigator: DestinationsNavigator,
dataViewModel: DataViewModel,
qrUrl : String,
doRemoveOrderList:() -> Unit,
doCancelOrder:(orderItem: OrderItem) -> Unit
) {

// 이미지 만들 준비
val writer = MultiFormatWriter()
var bitmap: Bitmap? = null
val encoder = BarcodeEncoder()

var context = LocalContext.current

// qrUrl 이라는 string 을 이미지로 변환
try {
val matrix: BitMatrix =
writer.encode(qrUrl, BarcodeFormat.QR_CODE, 300, 300)
bitmap = encoder.createBitmap(matrix)
} catch (e: Exception) {
Toast.makeText(
context,
"QR 생성 실패",
Toast.LENGTH_SHORT
).show()
}

...

Column( modifier = Modifier
.fillMaxWidth(),
) {
...
LazyColumn(
modifier = Modifier
.fillMaxWidth()
,
contentPadding = PaddingValues(horizontal = 3.dp),
verticalArrangement = Arrangement.Top
) {
item {
Row(
modifier = Modifier
.fillMaxWidth(),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically
) {
// 이미지가 생성 되었다면 image 에 넣어 보여 주기
if (bitmap != null) {
Image(
bitmap = bitmap.asImageBitmap(),
contentDescription = "bitMap",
modifier = Modifier
.width(200.dp)
.height(200.dp),
)
}
}

...
}
}
}

}

이미지로 변환된 QRCode 을 화면에서 활용하기 때문에 어떤 것이듯 QRCode 로 변환해 볼 수 있습니다.  예시 코드에서는 URL로 받아온 string을 변환해 보았습니다. 


 


qrcode 가 생성된 예시



 


이렇게 해서 생성된 예시를 볼 수 있습니다.   다양하게 활용할 수 있지 않을까 하는 생각이 듭니다. 이 기능을 활용한 앱은  2 가지입니다. 


 


https://play.google.com/store/apps/details?id=com.billcoreatech.boss0426&pli=1 



 


우연히 사장 - Google Play 앱


우연히 사장님들께 간편한 바코드 인식기능이 있는 계산기를 제공해 드립니다.


play.google.com




https://play.google.com/store/apps/details?id=com.billcoreatech.bespeak1003 



 


주문이요, 미니키오스크, 간편결제 (payapp 연동) - Google Play 앱


매장안에 있는 테이블에서 주문을 실시간으로 받고 주방으로 전달해 앱 입니다. 가장 저렴한 키오스크를 마련해 보세요


play.google.com




 


한번 적용된 모습을 보시는 것은 어떨까요?


 


zxing 을 만들고 공유해 주시는 개발자 및 서포터님들께 감사 인사를 드립니다.





오늘의 이야기

우리가 즐겨 쓰는 카톡에도 챗봇이 있다네요.
해서 챗봇과 놀아보기 2탄입니다.

카카오톡에서 챗봇은 채널 추가를 해야 합니다.
친구목록 화면에서 채널 검색을 통해 AskUp을 찾아보세요.

채널이 추가되면 그 친구와 대화를 시도해 보세요.
저는 지난번에 openAi에게 물었던 것을 다시 물어보았어요







결국 비슷한 결과를 얻기는 했어요.

심심할 때 같이 놀아보세요. 그리고 혹시 koGpt 가 궁금하시면 아래 앱도 한번 받아 보세요.

https://play.google.com/store/apps/details?id=com.billcorea.sudabot0222

수다떨기 (챗봇 대화) - Google Play 앱

심심할 때 수다을 떨어 보세요... 챗봇이 응답해 드립니다.

play.google.com


챗봇과 수다를 떨어 볼 수 있거든요.





오늘의 이야기



#스치니1000프로젝트 #재미 #행운기원 #Compose #Firebase

🎯 야 너 토요일마다 로또 확인하냐?
나도 맨날 "혹시나~" 하면서 봤거든 ㅋㅋ

근데 이제는 그냥 안 해
AI한테 맡겼어 🤖✨

그것도 구글 Gemini로다가!

그래서 앱 하나 만들었지
👉 "로또 예상번호 by Gemini" 🎱

AI가 분석해서 번호 딱! 뽑아줌
그냥 보고 참고만 하면 됨

재미로 해도 좋고…
혹시 모르는 거잖아? 😏


https://play.google.com/store/apps/details?id=com.billcorea.gptlotto1127




오늘의 이야기

https://developer.android.com/training/constraint-layout?hl=ko 



 


ConstraintLayout으로 반응형 UI 빌드  |  Android 개발자  |  Android Developers


컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. ConstraintLayout으로 반응형 UI 빌드   Android Jetpack의 구성요소 ConstraintLayout을 사용하면 플랫 뷰 계층 구조(중첩


developer.android.com




 


 


ConstraintLayout

개발자 가이드를 읽어 봅니다.  눈 씌고 찾아보아도 jetpack compose에서 ui 구현하는 이야기는 없습니다.  이 layout  을 사용하는 이유는 개발자 가이드에서 설명하고 있는 것처럼 UI에 배치를 유연하게 하는 것이 목적일 수 있습니다. 


 


예전에 개발하던 xml 방식의 layout  파일에서는 배치 하고자 하는 항목들을 드래그해서 위치를 잡아 주는 것 만으로 유연하게 design을 할 수 있었습니다. 


 


jetpack compose 을 활용한 작업을 하는 동안에 그 생각이 났더랍니다. 유연하게 배치를 할 수 있는 방법이 뭐가 있을까 하고 말입니다. 


 


gradle 설정

 


// constraintlayout
implementation "androidx.constraintlayout:constraintlayout-compose:1.1.0-alpha08"

개발자 가이드에도 나와 있기는 하지만, 잘 보이지 않았던 것입니다.  꼼꼼하게 읽어 보지도 않지만요.


아무튼 이번에 알게 되어 사용을 해 보았습니다. 


 


개발자 가이드에서 말하고 있는 것처럼 전체 화면에 배치를 하면서 이전 배치한 요소의 하단에  다음 배치할 요소를 연결하는 방식으로 배치할 수 있는 데 compose에서는 어떻게 그것을 구현했을 까요?


 


    val configuration = LocalConfiguration.current
val screenWidth = configuration.screenWidthDp.dp
val screenHeight = configuration.screenHeightDp.dp

ConstraintLayout {
// 배치 되는 요소들의 목록 집합
val (runBtn, passwordEntry) = createRefs()

if (packCheck.value) {
Row(
modifier = Modifier
.constrainAs(runBtn) { // 위치 지정해 보기
top.linkTo(parent.top, margin = 50.dp)
start.linkTo(parent.start, margin = (screenWidth * 0.8f).value.dp)
end.linkTo(parent.end, margin = 50.dp)
},
) {
TextButton(onClick = {
doRunApk(runApkInfo)
}) {
Image(
modifier = Modifier
.width(100.dp)
.height(100.dp),
painter = painterResource(id = R.drawable.ic_runapp_png),
contentDescription = "run Order App",
)
}
}
}

Row(
modifier = Modifier
.constrainAs(passwordEntry) { // 위치 지정해 보기
top.linkTo(parent.top, margin = screenHeight * .4f)
start.linkTo(parent.start, margin = (screenWidth * .4f).value.dp)
}
) {
OutlinedTextField(
modifier = Modifier
.padding(3.dp)
.width(250.dp),
value = password,
onValueChange = {
password = it.replace("[^0-9]".toRegex(), "")
Log.e("", "password=$password")
if (password.length == 4) {
doPasswordCheck(password)
password = ""
}
},
placeholder = {
Text(text = stringResource(id = R.string.msgEnterPassword))
},
singleLine = true,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.NumberPassword),
visualTransformation = PasswordVisualTransformation(),
textStyle = typography.displayLarge
)
}
}

제일 바깥쪽에 ConstraintLayout 로 감싸고 그 안에 배치할 것을 추가합니다. 예제에서는 2개의 요소만 배치를 했기 때문에  선언된 것도 2개뿐 입니다만, 여러 개 있다면 그것들을 다 기술해 주어야 합니다. 그리고 각 요소들의 Modifier.constrainAs을 활용하여 위치 지정을 시작합니다. 


 


예제에서는 parent 라고 기술되는 제일 상위 ConstraintLayout으로부터 위치만 지정하도록 구성을 해 보았지만, parent 대신에 이전 요소인 runBtn 등의 이름이 적용될 수 도 있습니다. 


 


이제는 화면 전체에 자유자재로 요소들을 배치하여 유연한 UI도 만들어 볼 수 있을 듯 합니다. 


 


배치 예시



 





오늘의 이야기


#스하리1000명프로젝트

스치니들!
내가 만든 이 앱은, 내 폰에 오는 알림 중에서 중요한 키워드가 있는 경우
등록해둔 친구에게 자동으로 전달해주는 앱이야 📲

예를 들어, 카드 결제 알림을 와이프나 자녀에게 보내주거나
이번 달 지출을 달력처럼 확인할 수도 있어!

앱을 함께 쓰려면 친구도 설치 & 로그인해줘야 해.
그래야 친구 목록에서 서로 선택할 수 있으니까~
서로 써보고 불편한 점 있으면 알려줘 🙏

👉 https://play.google.com/store/apps/details?id=com.nari.notify2kakao





오늘의 이야기

1인 개발자가 되어 살아 보는 게 소원(?)일까는 모르겠으나,  이전 회사에서 퇴직하고 2달을 놀았고,  1인 개발자가 되어 2달이 넘어가는 지금도 마치 휴식기인 것 같이 거의 백수와 같은 삶을 살고 있다. 


 


매화



여유가 있다면야 준)정년으로 퇴직한 내가 무슨 일을 해야 할까 하는 생각이 들기도 하겠지만, 아직도 살아야 할 날이 많이 남아 있고, 그날들을 이렇게 채워 가야 한다는 것이 부담스럽게 느껴지는 지금이기도 하다.


매화



더 열불나게 살아야 하는 가 하는 생각이 머리를 채우는 아침이기도 하고...  이제 정말 텅장이 되어 가고 있는 나의 금고(?)가 너무 가벼워져 더는 어떻게 할 수 없을 것 같은 아쉬움이 머리를 채우는 아침이기도 하다.


 


지난 주말 친구 모임을 갔던 곳에서 찍은 매화꽃 ... 이제 정말 봄이 이 만큼 와 있는 데, 아직도 나에게는 겨울이 남아 있는 것 같아... 


 


마음을 추스리고  퇴직하면서 남겼던 글처럼... 취해 있지 않고 열심히 살아 보련다.   아직 살아야 할 날이 남아 있으니 말이다.


 



 





오늘의 이야기

챗봇과 대화 시작



 


오늘은 챗봇과 스무고개 게임에 대한 이야기를 잠시 해 보았습니다.   챗봇에게 나의 의도를 설명하고  그 놀이를 할 수 있는지 물어보았고, 챗봇은 흔쾌히(?) 가능하다고 합니다.  해서 챗봇과 질문과 응답을 해 보았습니다. 


챗봇이 외국계이기 때문에 질문은 영어로 하고 답도 영어로 받습니다.  여기서 번역은 구글 번역기를 활용 했습니다.  혹시나 영어를 잘하는 것으로 오해를 하실까 싶어 미리 밝힙니다. ㅋㅋ~



 



내가 한 질문: I want to play a question and answer game with you. The method of the game is that you remember the name of an object and I match it.
I'm going to ask you 20 questions before you tell me the answer, you have to answer it like this, right, wrong, similar, and after the 20 questions are over, it's a game where you tell me if the answer I'm talking about is right or not.
If the answer I said is wrong even after 20 questions, you win the game, and if I got it right, I win the game.
can i do it



답 : Yes, I can play the question and answer game with you. Let's get started!


 


내가한 질문 : Then did you start remembering one thing?


답 : Yes, I have something in mind. You can start asking your questions.


 


내가한 질문 :  is it an animal
답 : No, it is not an animal.


 


내가한 질문 : is it a thing
답 : Yes, it is a thing.


 


내가한 질문 : can it ride
답 : Yes, it is possible for this thing to be ridden.


 


내가한 질문 : is it a car
답 : No, it is not a car.


 


내가한 질문 : Does it have an engine
답 : Yes, it has an engine.


 


내가한 질문 : does it have two wheels
답 : Yes, it has two wheels.


 


내가한 질문 : is it a motorcycle
답 : Yes, it is a motorcycle.


 


내가한 질문 : Wow... I won, right?
답 : Yes, that's correct! You correctly guessed that the thing I was thinking of is a motorcycle. Congratulations, you win the game!


 


내가한 질문 : Did my number of questions exceed the first 20?
답 : No, you correctly guessed the answer within the first 6 questions, so we didn't need to go through all 20 questions. Well done!


 


내가한 질문 : Can you make a game like this with python code
답 : Yes, it is possible to create a similar game using Python code. Here is some sample code to get you started:


import random

# Create a list of items to be guessed
items = ["motorcycle", "bicycle", "scooter", "skateboard", "rollerblades", "unicycle"]

# Select a random item from the list
selected_item = random.choice(items)

# Define a function to play the game
def play_game(item):
guesses = 0
max_guesses = 20
while guesses < max_guesses:
guesses += 1
guess = input("Guess the item: ")
if guess == item:
print("Congratulations, you win!")
return
elif guesses == max_guesses:
print(f"Sorry, you've used all {max_guesses} guesses. The item was {item}.")
return
else:
print("Incorrect guess. Please try again.")

# Play the game with the selected item
play_game(selected_item)


This code randomly selects an item from a list and allows the user to guess the item within 20 attempts. If the user correctly guesses the item, the program ends with a congratulatory message. If the user uses all 20 guesses and still hasn't correctly guessed the item, the program ends with a message revealing the correct answer. You can modify the list of items to make the game more challenging or interesting.


 


내가한 질문 : There doesn't seem to be a function in this code to answer a question like you do.
Can't you create a code that thinks and answers when you ask a question like I did with you?


 


답 :  Ah, I understand what you're asking now. I apologize for the confusion earlier.
What you're describing is a natural language processing (NLP) chatbot that can understand and respond to user input. While it's possible to create a simple NLP chatbot using Python, it's a complex task that requires significant knowledge in machine learning and natural language processing.
There are various libraries and frameworks available in Python for developing NLP chatbots, such as spaCy, NLTK, and TensorFlow. However, creating a sophisticated chatbot that can understand and respond to a wide range of user input requires significant development effort and training data.
If you'd like to learn more about developing chatbots with Python, there are many online tutorials and resources available that can help you get started.


 


내가한 질문 : Can you recommend just 20 online tutorials and resources?


답 :  Sure, here are 20 online tutorials and resources for learning about chatbot development with Python:



  1. Building a Simple Chatbot from Scratch in Python (using NLTK): https://towardsdatascience.com/building-a-simple-chatbot-in-python-using-nltk-7c8c8215ac6e

  2. Creating a Chatbot with Deep Learning, Python, and TensorFlow: https://www.digitalvidya.com/blog/creating-a-chatbot-with-deep-learning-python-and-tensorflow/

  3. How to build a chatbot in 3 easy steps with Python: https://www.freecodecamp.org/news/how-to-build-a-chatbot-with-python/

  4. Building Chatbots in Python - A Tutorial: https://stackabuse.com/building-chatbots-in-python-a-tutorial/

  5. How to Build Your First AI Chatbot Using Python: https://www.twilio.com/blog/how-to-build-a-chatbot-with-python

  6. Chatbot with Python - A Step-by-Step Tutorial: https://blog.hathix.com/chatbot-with-python-a-step-by-step-tutorial/

  7. How to Create a Chatbot with Python in Just 3 Steps: https://www.activestate.com/blog/how-to-create-a-chatbot-with-python-in-just-3-steps/

  8. Building an Intelligent Chatbot Using Python: https://www.analyticsvidhya.com/blog/2020/01/building-a-chatbot-using-deep-learning/

  9. Python Chatbot Tutorial - Chatbot with Deep Learning: https://data-flair.training/blogs/python-chatbot-project/

  10. How to Build Chatbots with Rasa: https://rasa.com/docs/getting-started/

  11. Building Chatbots with ChatterBot: https://chatterbot.readthedocs.io/en/stable/

  12. Chatbot Development with Python and ChatterBot: https://www.geeksforgeeks.org/chatbot-development-with-python-and-chatterbot/

  13. Creating Chatbots with Python in a Few Easy Steps: https://www.ubuntupit.com/creating-chatbots-with-python-in-a-few-easy-steps/

  14. Python Chatbot Tutorial: Build Your First AI Chatbot: https://www.edureka.co/blog/python-chatbot-tutorial/

  15. Building a Rule-Based Chatbot with Python, Flask, and Dialogflow: https://towardsdatascience.com/building-a-rule-based-chatbot-with-python-flask-and-dialogflow-246ebcd2a5a5

  16. How to Build a Chatbot with Python and Telegram: https://www.twilio.com/blog/how-to-build-a-chatbot-with-python-and-telegram

  17. Creating a Chatbot with Python, Flask, and Dialogflow: https://medium.com/@josh_tillman/creating-a-chatbot-with-python-flask-and-dialogflow-5ed05656fcea

  18. Python Chatbot Tutorial - Dialogflow: https://data-flair.training/blogs/python-chatbot-dialogflow/

  19. Building a Conversational Chatbot with Rasa and Python: https://www.analyticsvidhya.com/blog/2021/03/building-a-conversational-chatbot-with-rasa-and-python/

  20. Python Chatbot with NLTK and Text-to-Speech: https://www.section.io/engineering-education/python-chatbot-with-nltk-and-text-to-speech/


I hope you find these resources helpfu


 


내가한 질문 : thank you so much
답 : You're welcome! Don't hesitate to reach out if you have any further questions or if there's anything else I can help you with.


 




대화중에 파이썬 코드로 스무고개 게임을 할 수 있는 코드를 구현해 달라고 했더니 그것도 흔쾌히 해 주기는 했습니다만, 나의 의도와 다르길래 그 이야기를 했더니 이해를 했다면서 공부를 해야할 부분에 대한 조언도 해 주었습니다. 


 


그래서 20개의 온라인 자습서나 리소스를 알려 달라고 해서 받았습니다.  다 영어로 되어 있는 정보들이라서... 흠...


하나씩 배워 나가 봐야 할 것 같습니다. 


 


오늘도 화이팅~





오늘의 이야기


#스하리1000명프로젝트,
가끔 외국인 노동자들과 대화가 힘들 때가 있죠?
도움이 되는 간단한 앱을 만들어 봤습니다! 당신은 당신의 언어로 글을 쓰고, 다른 사람들은 그것을 그들의 언어로 봅니다.
설정에 따라 자동 번역됩니다.
쉬운 채팅에 매우 편리합니다. 기회되면 꼭 보세요!
https://play.google.com/store/apps/details?id=com.billcoreatech.multichat416




오늘의 이야기

물론 50대 중년 남성이 일자리를 찾을 때 염두에 두어야 할 20가지 사항은 다음과 같습니다.

1. 가장 최근의 업적과 기술을 강조하도록 이력서를 업데이트하십시오.
2. 이전 동료, 친구 및 가족과 네트워크를 형성하여 직업 리드 및 추천을 받으세요.
3. 채용 박람회 및 업계 회의에 참석하여 잠재적인 고용주를 만나고 취업 기회에 대해 알아보세요.
4. 기술을 업데이트하고 시장성을 높이기 위해 직업 훈련이나 인증을 찾는 것을 두려워하지 마십시오.
5. LinkedIn과 같은 소셜 미디어 플랫폼을 활용하여 전문 네트워크를 구축하고 경험을 선보이세요.
6. 경력에 고용 공백이나 경력 변경 사항을 설명할 준비를 하십시오.
7. 잠재적인 고용주를 조사하고 필요에 맞게 이력서와 커버레터를 조정하십시오.
8. 취업 기회를 찾는 데 도움이 되는 채용 담당자 또는 인력 대행사와 협력하는 것을 고려하십시오.
9. 구직 과정 내내 긍정적이고 열정적인 태도를 유지하십시오.
10. 원래 경력 경로와 일치하지 않을 수 있는 직업 기회에 대해 유연하고 열린 마음을 가지십시오.
11. 기꺼이 낮은 수준에서 시작하거나 임시 또는 계약직 역할을 맡아 경험을 쌓고 자신의 가치를 증명하십시오.
12. 면접 기술을 연습하고 어려운 질문에 답할 준비를 하십시오.
13. 전문적인 복장을 하고 인터뷰를 위해 일찍 도착하십시오.
14. 열정을 보여주고 면접 중에 사려 깊은 질문을 하여 직업에 대한 관심을 보여주세요.
15. 인터뷰 후 감사 노트를 작성하여 감사를 표현하고 해당 업무에 대한 관심을 다시 한번 확인하십시오.
16. 참고 문헌 목록을 준비하고 그들이 당신이 구직 중이라는 것을 알고 있는지 확인하십시오.
17. 채용 제안을 받은 후 급여와 혜택을 협상할 준비를 하십시오.
18. 구직이 예상보다 오래 걸리더라도 정신을 차리고 동기를 유지하십시오.
19. 기술을 구축하고 전문 네트워크를 확장하기 위해 자원 봉사나 프리랜서 작업을 고려하십시오.
20. 풍부한 경험, 지식 및 성숙도를 직장에 가져오므로 나이가 자산이 될 수 있음을 기억하십시오.


 


 


오늘도 구직을 준비하는 50대 중후반의 여러분을 응원합니다. 나를 포함하여...


 


이상 20가지의 조언은 챗봇에게서 받은 답 이였습니다.






오늘의 이야기

Local IP

오늘은 앱을 구현하는 동안에 필요했던 network interface을 통해서 Local IP을 얻어오는 코드에 대한 기술을 해 볼까 합니다. 


 


@Throws(SocketException::class)
fun getLocalIpAddress(): String {

//Device에 있는 모든 네트워크에 대해 뺑뺑이를 돕니다.
val en = NetworkInterface.getNetworkInterfaces()
while (en.hasMoreElements()) {
val intf = en.nextElement()

//네트워크 중에서 IP가 할당된 넘들에 대해서 뺑뺑이를 한 번 더 돕니다.
val enumIpAddr = intf.inetAddresses
while (enumIpAddr.hasMoreElements()) {
val inetAddress = enumIpAddr.nextElement()

//네트워크에는 항상 Localhost 즉, 루프백(LoopBack)주소가 있으며, 우리가 원하는 것이 아닙니다.
//IP는 IPv6와 IPv4가 있습니다.
//IPv6의 형태 : fe80::64b9::c8dd:7003
//IPv4의 형태 : 123.234.123.123
//어떻게 나오는지는 찍어보세요.
if (inetAddress.isLoopbackAddress) {
Log.e("IPAddress", "ip=" + intf.displayName + "(loopback) | " + inetAddress.hostAddress)
} else {
Log.e("IPAddress", "ip=" + intf.displayName + " | " + inetAddress.hostAddress)
}
if (!inetAddress.isLoopbackAddress && inetAddress is Inet4Address) {
Log.e("", "")
return inetAddress.getHostAddress().toString()
}
}
}
return ""
}

물론 코드는 kotlin 코드 입니다. 구글링을 많이 해 보아도 java로 되어 있는 코드들은 많은데, kotlin 으로 되어 있는 코드는 잘 찾기가 힘이 듭니다. 해서 이번에 찾은 코드를 기록해 두려고 합니다.  그래야 나중에 또 사용할 일이 생길 수 있으니까요


 


우리가 찾는 IP 주소는 IPv4, IPv6 등등이 있을 수 있습니다.  IPv6은 이제 너무 많아서 포화 상태가 되어가는 IPv4의 확장판이라고 보면 될 것 같습니다. 아직 까지는 IPv4로 지칭 되는 192.168.0.1 형식의 IP주소가 나오게 됩니다. 


 


실행된 모습은 직접 만들어서 확인해 보시면 좋을 듯 합니다.   그래야 또 하나 배움의 길로 들어설 테니 말입니다.


 





오늘의 이야기


#billcorea #운동동아리관리앱
🏸 Schneedle, a must-have app for badminton clubs!
👉 Match Play – Record Scores & Find Opponents 🎉
Perfect for anywhere, alone, with friends, or in a club! 🤝
If you like badminton, definitely try it

Go to app 👉 https://play.google.com/store/apps/details?id=com.billcorea.matchplay




오늘의 이야기

Zxing 은 qrcode, barcode 인식을 위해서 공유되는 open source 라이브러리입니다.  오늘은 이것을 활용해서 QRCode 을 만들어서 앱에 공유 하는 이야기를 해 보고자 합니다.  이전 포스팅을 통해서 barcode 을 생성해 주...