удалить
var jsonStringArray=intent.getStringExtra("Test")
из MainActivity2
class MainActivity2: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle ? ) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
GetJsonWithOkHttpClient(this.text).execute();
val test = GetJsonWithOkHttpClient(this.text).execute().get()
System.out.println("ABC Value is $test")
val intent = Intent(this @MainActivity2, MainActivity::class.java)
intent.putExtra("Test", test)
startActivity(intent)
System.out.println("TestValue: $jsonStringArray")
}
или
ваша основная активность должна быть
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle ? ) {
super.onCreate(savedInstanceState)
val test="your value"
val intent = Intent(this@MainActivity,MainActivity2::class.java)
intent.putExtra("Test",test)
}
}