嗨,我需要实现这样的浮动地图
我的应用程序将在后台运行,当用户到达某个位置时,此弹出窗口应出现,其中包含来自 admob 的谷歌地图和横幅广告
就像 truecaller 所做的那样
我尝试使用制作地图作为小部件,但这就是我在这个主题的服务中得到的 android java 如何制作像谷歌导航地图这样的浮动地图?
所以我现在尝试将地图活动作为画中画
这是我的代码
公共类 MainActivity 扩展 AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
openPicInPic();
}
private void openPicInPic(){
Timer timerObj = new Timer();
TimerTask timerTaskObj = new TimerTask() {
public void run() {
Intent intent = new Intent(MainActivity.this, MapActivity.class);
startActivity(intent);
}
};
timerObj.schedule(timerTaskObj, 5000);
}
这是我的 mapActivity ( mapview )
public class MapActivity extends Activity implements OnMapReadyCallback {
private MapView mMapView;
private static final String MAPVIEW_BUNDLE_KEY = "MapViewBundleKey";
@Override
public void onUserLeaveHint () {
startPicInPic();
}
private void startPicInPic() {
PictureInPictureParams pictureInPictureParams = new PictureInPictureParams.Builder().build();
enterPictureInPictureMode(pictureInPictureParams);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_activity);
// *** IMPORTANT ***
// MapView requires that the Bundle you pass contain _ONLY_ MapView SDK
// objects or sub-Bundles.
Bundle mapViewBundle = null;
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY);
}
mMapView = (MapView) findViewById(R.id.map);
mMapView.onCreate(mapViewBundle);
mMapView.getMapAsync(this);
startPicInPic();
}
显现
<activity android:name=".MapActivity"
android:supportsPictureInPicture="true"
android:configChanges= "screenSize|smallestScreenSize|screenLayout|orientation"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
/>
当我将应用程序放在后台并运行时间时,当计时器运行时,它总是打开带有地图的应用程序,我只需要如上图所示显示地图