코틀린18 Kotlin] 안드로이드 스튜디오 인터넷 연결 상태 확인 // 인터넷 연결 확인 fun checkInternetConnection() : Boolean { val cm = getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager val activeNetwork: NetworkInfo? = cm.activeNetworkInfo if (activeNetwork != null) return true return false } 연결 상태 확인 및 모니터링 | Android 개발자 | Android Developers 반복적인 알람과 백그라운드 서비스를 사용하는 가장 일반적인 방법은 인터넷 리소스의 애플리케이션 데이터 정기 업데이트를 예약하거나, 데이터를 캐싱하거나, 오래 진행되는 다운로드를 실 developer.a.. 2020. 8. 8. Kotlin] 안드로이드 스튜디오 AlertDialog 위치 Changing position of the Dialog on screen android I made a simple AlertDialog in my Activity: View view = layoutInflater.inflate(R.layout.my_dialog, null); AlertDialog infoDialog = new AlertDialog.Builder(MyActivity.this) .set... stackoverflow.com val alertDialog = builder.create() val window = alertDialog.window // 위쪽 window?.setGravity(Gravity.TOP) alertDialog.show() 전체코드 val builder = AlertDi.. 2020. 8. 8. Kotlin] 안드로이드 스튜디오 뒤로가기 두번 눌러 앱 종료 // 뒤로가기 2번 private var backPressedTime : Long = 0 override fun onBackPressed() { Log.d("TAG", "뒤로가기") // 2초내 다시 클릭하면 앱 종료 if (System.currentTimeMillis() - backPressedTime < 2000) { finish() return } // 처음 클릭 메시지 Toast.makeText(this, "'뒤로' 버튼을 한번 더 누르시면 앱이 종료됩니다.", Toast.LENGTH_SHORT).show() backPressedTime = System.currentTimeMillis() } 2020. 6. 14. Kotlin] ListPreference 선택값 summary에 반영 val backgroundColorCategoryPref = findPreference("backgroundColorCategory") as ListPreference // 선택값 summary에 반영 backgroundColorCategoryPref.setOnPreferenceChangeListener { preference, newValue -> if (preference is ListPreference) { val index = backgroundColorCategoryPref.findIndexOfValue(newValue.toString()) backgroundColorCategoryPref.summary = backgroundColorCategoryPref.entries[index] } Log... 2020. 4. 4. 이전 1 2 3 4 5 다음