![](/img/trans.png)
[英]How can I create an animation class to use in other activities in android?
[英]Android: how to create and hold mapview in memory for all activities to use
我想减少我的应用程序中Google地图的启动时间。 我要花一些内存,但要在启动时创建mapview,然后在需要它的任何活动中使用它,而不会在应用程序运行时破坏和重新创建它。 这可能吗? 我所看到的问题是,除非在布局中使用mapview,否则它实际上不会初始化,并且随着用户在活动之间移动,连续的布局会被破坏。
<com.google.android.gms.maps.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraZoom="13"
map:mapType="normal"
map:uiZoomControls="false"
map:uiRotateGestures="true"
map:uiScrollGestures="true"
map:uiZoomGestures="true"
map:uiTiltGestures="false" />
我看不出有什么理由要在活动的生命周期中进行搜索。 要实现所需的功能,您需要获取地图/活动的当前状态并将其保存在onPause
和onDestroy
方法中。 然后在onCreate
和onResume
您可以检查是否有任何保存的状态,如果可以,请使用自己的逻辑k BUT在地图和本地化的情况下恢复它,我认为这不是一个好主意
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.