N
N
NNull2020-05-15 10:33:12
Java
NNull, 2020-05-15 10:33:12

How to correctly access MainActivity from another class?

I have a test application, its essence is to unlock the application (like AppLock)
all tasks lie on the ActCheck.java class , it is in the same package as MainActivity.java
ActCheck has direct access to the MainActivity fields and performs Read / Change fields.
To access the MainActivity.java elements through the ActCheck.java class , I use the static modifier so as not to create the MainActivity


object The question (problem) itself:
Is it possible to do otherwise? It is in this situation, without assigning the static modifierall the fields and methods that I want to access from another class, because I am now reading that the static modifier is not thread-safe and constantly gives me a warning from AndroidStudio, about - Do not put the Android context in static fields, this is a memory leak , but I need it with TextView / EditText to work (read/change) using the ActCheck.java
class How to properly access MainActivity.java from the ActChekc.java class ? is it possible without static

I am a beginner and perhaps a stupid, not exactly posed question, but still.
If you need a code - write

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question