I'm new to android development. I'm learning how to make an app in Kotlin. On my MainActivity.kt, I have the code below:
recordBtn.setOnClickListener{
val intent = Intent(this, com.example.testapp.data.RecordActivity::class.java)
startActivity(intent)
}
For some reason, I can use the update password and logout buttons on the screen, but when I press the record button to go to activity_record.xml I just get a blank white screen. This is the onCreate for my RecordActivity.kt:
@RequiresApi(Build.VERSION_CODES.M)
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
super.onCreate(savedInstanceState, persistentState)
setContentView(R.layout.activity_record)
Log.e("Record Activity","Reached the onCreate of the RecordActivity")
requestPermissions(permissions, REQUEST_RECORD_AUDIO_PERMISSION)
// recordbtn = findViewById(R.id.recordbtn)
// playbtn = findViewById(R.id.playbtn)
recordbtn = RecordButton(this)
playbtn = PlayButton(this)
filename = "${externalCacheDir?.absolutePath}/recording.mp3"
mr = MediaRecorder()
mr?.setAudioSource(MediaRecorder.AudioSource.MIC)
mr?.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
mr?.setOutputFile(filename)
mr?.setAudioEncoder(3) //AAC; need to review what the best choice here is.
mr?.prepare()
}
I feel like the problem might be that my RecordActivity.kt is in another folder than the other activities.