It ends with this error: cannot find symbol
Page1.text(someContext.getString(R.string.Some_Text), false,false);
^
symbol: variable Page1
location: class Page2
Why cannot find symbol? Some problem with Page1.text?
Yes! I’m only added some things into OpenTracks. So I’ve got class UploadAsync where I’ve got this things (for example in onPreExecute or in onPostExecute):
public class UploadAsync extends AsyncTask<Void, Void, String> {
…
UploadActivity.text(uploadContext.getString(R.string.Upload_Wait), false,false);
UploadActivity.toast(uploadContext, uploadContext.getString(R.string.Upload_Wait));
…
}
And:
class UploadActivity : AbstractActivity() {
… @JvmStatic
fun text(text: String?, show: Boolean?, result: Boolean) {
if (result) {
viewBinding?.buttonRun?.setVisibility(View.GONE)
viewBinding?.buttonDone?.setVisibility(View.VISIBLE)
viewBinding?.uploadDoneText?.setVisibility(View.VISIBLE)
} else {
viewBinding?.buttonRun?.setText(text)
if (show != null) {
viewBinding?.buttonRun?.setEnabled(show)
}
}
}
…
}
Anything else of content is unrelated. I think. I need to call function “text” from other classes.
If text() is defined inside the UploadActivity class, then it is a member function and it requires an instance of UploadActivity in order to be invoked. Kotlin doesn’t support static members. Please read about companion objects.
As I said, it is not a static function and it can’t be invoked like this: UploadActivity.text(). You need an instance of UploadActivity to invoke it. If you wanted text() to be a static function, then again, Kotlin doesn’t support this. Create a top-level function or use a companion object.