【问题标题】:Launch activity from previous Fragment freezes app从以前的 Fragment 启动 Activity 冻结应用程序
【发布时间】:2016-02-01 18:12:45
【问题描述】:

我有一个应用程序,它有一个片段 (FragmentMap),其中包含一个地图和一个回收站视图。在这个片段中,如果我单击标记或列表项,我可以打开一个新活动来显示该对象的详细信息。 问题是:当我按下 DetailAcativity 内的后退按钮时,我回到 FragmentMap,如果尝试打开 DetailActivity 或我的应用程序的任何其他 Activity,它会简单地冻结并显示消息“......没有响应”。

ps:我正在使用 android 注释库

我以这种方式启动 DetailActivity:

private void selectItem(View view, int position, Place place) {
        String placeJson = new Gson().toJson(place);
        Intent it = new Intent(getActivity(), PlaceDetailActivity_.class);
        it.putExtra(BundleKeys.PLACE_JSON, placeJson);
        if (location != null) {
            it.putExtra(BundleKeys.LATITUDE, location.getLatitude());
            it.putExtra(BundleKeys.LONGITUDE, location.getLongitude());
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Pair<View, String> p1 = new Pair<>(view.findViewById(R.id.iv_image_place), "place_image");
            Pair<View, String> p2 = new Pair<>(view.findViewById(R.id.tv_place_name), "place_name");
            ActivityOptions options = ActivityOptions
                    .makeSceneTransitionAnimation(getActivity(), p1, p2);
            getActivity().startActivity(it, options.toBundle());
        } else {
            getActivity().startActivity(it);
        }
    }

有什么想法吗?

【问题讨论】:

  • 你能把DetailsActivity的代码也贴出来吗?它有帮助
  • 嗨 Witalo,您解决了吗?

标签: android android-fragments android-activity


【解决方案1】:

我会建议您将您的真实设备连接到计算机并查看错误日志并查看导致应用程序崩溃的原因,我的意思是日志记录的错误类型。可能,您的 fragmentManager 在 onResume 或其他内容中失败。尝试连接手机以查看错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-19
    • 2015-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-06
    • 2017-07-20
    • 2012-02-03
    相关资源
    最近更新 更多