You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My Application has two activities: MainActivity and TomtomMapActivity;
MainActivity: used to jump to TomtomMapActivity;
TomtomMapActivity: used to display Tomtom maps;
After jumping from MainActivity to TomtomMapActivity, quickly pan or zoom the map. When the map data is not yet fully rendered, immediately return to the previous page of MainActivity and finish TomtomMapActivity. Then my Application will experience ANR and cannot perform any operations.
2.The code is as follows:
class MainActivity : AppCompatActivity() {
lateinit var vb: ActivityMainBinding
SDK version:
model :
SM-A5160 Android 13
1.Problem description :
2.The code is as follows:
class MainActivity : AppCompatActivity() {
lateinit var vb: ActivityMainBinding
}
class TomtomMapActivity : AppCompatActivity() {
private lateinit var vb : ActivityTomtomMapBinding
private lateinit var mapShow :TomMapControl
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
vb = ActivityTomtomMapBinding.inflate(layoutInflater)
setContentView(vb.root)
}
class TomMapControl {
private var mTomtomMap: TomTomMap? = null
private var tomtomMapFragment: MapFragment? = null
private var mActivity: FragmentActivity? = null
private var mapContain: FrameLayout? = null
private val defualtLocation: GeoPoint = GeoPoint(22.357942, 106.845056)
private val DEFAULT_ZOOM = 17.0
fun showTomMap(
activity: FragmentActivity?,
frameLayout: FrameLayout?
) {
if (activity == null || frameLayout == null) {
return
}
mActivity = activity
frameLayout.removeAllViews()
mapContain = frameLayout
val fm = activity.supportFragmentManager
val transaction = fm.beginTransaction()
tomtomMapFragment = MapFragment.newInstance(getMapOptions()).apply {
transaction.replace(frameLayout.id, this)
transaction.commit()
getMapAsync {
onMapReady(it)
}
}
}
}
3.I need help, how can I solve the ANR situation described above?
The text was updated successfully, but these errors were encountered: