Converting classes

Finally, we will migrate our classes. We have two automatic options available. We will use both. Locate MigrationActivity.java and open it. Choose the Code | Convert Java file to the Kotlin file. It takes a couple of seconds to convert. Now, drag and drop the file from the Java package into the Kotlin sources package. Observe the following source code:

    package com.journaler.activity 
 
    import android.os.Bundle 
    import android.support.v7.app.AppCompatActivity 
 
    import com.journaler.R 
 
    class MigrationActivity : AppCompatActivity() { 
 
      override fun onCreate(savedInstanceState: Bundle?) { 
        super.onCreate(savedInstanceState) 
        setContentView(R.layout.activity_main) 
      } 
 
      override fun onResume() { 
        super.onResume() 
      } 
 
    } 

As we have mentioned, ...

Get Mastering Android Development with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.