import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.content.Intent import kotlinx.android.synthetic.main.activity_main.* class MainActivity : AppCompatActivity() { companion object { val PERMISSIONS_REQUEST_READ_CONTACTS = 100 } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) button1.setOnClickListener { startActivity { ProviderContactContract::class.java } } button2.setOnClickListener { startActivity { ProviderMediaStore::class.java } } } private fun <T : Any?> startActivity(clazz: () -> Class<T>) { val intent = Intent(this, clazz()) startActivity(intent) } }
0 comments:
댓글 쓰기