首页 / 浏览问题 / 移动GIS / 问题详情
AR SceneControl 和 ARCartographView 崩溃
6EXP 2022年11月18日

使用产品:SuperMap iMobile 10i(2021) SP1 for Android
问题详细描述:用Fragment在AR管线与AR测量切换时,程序退出
问题重现步骤: 

if ("scene".equals(type)){
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();

    if (sceneFragment == null) {
        sceneFragment = new SceneFragment();

    }
    fragmentTransaction.add(R.id.content_framelayout, sceneFragment, "sceneFragment");

    hideAllFragment(fragmentTransaction);
    fragmentTransaction
            .show(sceneFragment)
            .commit();

}else if ("cartograph".equals(type)){
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    if (cartographFragment == null) {
        cartographFragment = new CartographFragment();

    }
    fragmentTransaction.add(R.id.content_framelayout, cartographFragment, "cartographFragment");
    hideAllFragment(fragmentTransaction);
    fragmentTransaction
            .show(cartographFragment)
            .commit();
}

1个回答

您好,您这个问题应该是属于fragment跳转的问题,可以看一下fragment是否被销毁。网上也有很多fragment跳转问题的解答,您可以参考一下这个地址:java - Android中使用FragmentTransaction对象的add方法后应用闪退 - SegmentFault 思否

3,405EXP 2022年11月18日

不是fragment跳转问题,我把(SceneControl,ARCartographView)2个ar控件放一起,就直接崩溃

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    tools:context=".MainActivity">

    <com.supermap.realspace.SceneControl
        android:id="@+id/sceneControl"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <com.supermap.ar.arcartograph.ARCartographView
        android:id="@+id/ar_cartograph_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
ARCartographView实例不应该和SceneControl实例同时生存,您那边如果要切换,建议把上一个活动销毁再启动下一个活动哈
...