I have a native map view on the second activity. I would like to update the position of the dot from Flutter in the background. How can I get to access the activity so I can update the position?
I am new to Android Native. Thank you.
MainActivity.kt:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
GeneratedPluginRegister.registerGeneratedPlugins(FlutterEngine(this@MainActivity))
MethodChannel(flutterEngine?.dartExecutor!!, CHANNEL).setMethodCallHandler { call, result ->
if(call.method.equals("goToSecondActivity")){
goToSecondActivity()
} else if(call.method.equals("updatePosition")) {
val lat = call.argument<Double>("lat")
val long = call.argument<Double>("long")
val accuracy = call.argument<Double>("accuracy") ?: 7.170562529369844
val floorLevel = call.argument<Int>("floor") ?: 0
updatePosition(lat!!, long!!, accuracy, floorLevel)
} else {
result.notImplemented()
}
}
}
private fun goToSecondActivity() {
startActivity(Intent(this@MainActivity, SecondActivity::class.java))
}