Android
-
deprecated startActivityForResultAndroid 2021. 5. 28. 12:06
fun openActivityForResult() { startForResult.launch(Intent(this, AnotherActivity::class.java)) } val startForResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult -> if (result.resultCode == Activity.RESULT_OK) { val intent = result.data // Handle the Intent //do stuff here } } in Kotlin
-
[Android] 다른 앱 호출 후 결과 받기Android 2021. 3. 11. 13:43
TestA에서 TestB 호출하면서 데이터 같이 넘김 val intent = Intent() intent.setClassName("com.example.testb", "com.example.testb.MainActivity") intent.putExtra("data", "TestA") startActivityForResult(intent, 100) TestB에서 데이터 확인 intent.getStringExtra("data") TestB에서 반환 할 데이터 세팅 후 종료 intent.putExtra("result","resultData") setResult(100, intent) finish() TestA에서 반환 된 데이터 확인 override fun onActivityResult(requestCode..
-
[Android] StatusBar height 상태바 높이 구하기Android 2021. 3. 10. 15:50
/** * 상단 상태바 높이 계산 후 DP로 반환 * @param context Context * @return Int(DP값) */ fun getStatusBarHeightDP(context: Context): Int { var result = 0 val resourceId: Int = context.resources.getIdentifier("status_bar_height", "dimen", "android") if (resourceId > 0) { result = context.resources.getDimension(resourceId).toInt() } return result }
-
The 'kotlin-android-extensions' Gradle plugin is deprecated.Android 2021. 2. 15. 16:53
1. Kotlin synthetic Update View Bindings or Data Bindings in App level gradle file and then use binding instance 2. Parcelable Remove plugin kotlin-android-extension & add plugin kotlin-parcelize in App level gradle file In kotlin version 1.4.20