2 votes

Unresolved Reference in Kotlin

    package com.example.myapplication

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.provider.ContactsContract
import android.text.Editable
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_main3.*

    enum class ProviderType{
        BASIC
    }




class Homeactivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main3)
        val bundle =intent.extras
        bundle?.getString("email")
        bundle?.getString("provider")

        setup(email?: "", provider?: "")
    }
    private fun setup(email:String, provider: String){
        title ="Inicio"
        emailTextEdit.setText(email)
        providerTextEdit.setText(provider)
    }
}

In the code of setup(email?: "", provider?: "") email and provider they give me an Unresolved Reference error, and I don't know what to do anymore, I've been doing exhausted searches for a long time and I can't find any information, if someone can help me I would be very grateful.

1voto

Elenasys Points 67941

You get the error

Unresolved Reference

Because you are not defining the variables. When obtaining the bundle values, this is how you should receive the values and assign them to the method:

 var bundle :Bundle ?=intent.extras
var email = bundle!!.getString("email") 
var provider= bundle!!.getString("provider") 

setup(email?: "", provider?: "")

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X