android: I get no stacktrace, phone just hangs

前端 未结 2 1519
孤独总比滥情好
孤独总比滥情好 2020-12-05 12:04

My phone crashes after i pause my camera app, then switching back and take a picture. This only happens on my Samsung Galaxy S, on my Huwai device it totally works. I have f

2条回答
  •  我在风中等你
    2020-12-05 12:31

    I finally (after hours, almost days of debugging) solved this, by removing the preview view and re-instantiating it:

        @Override
        protected void onResume() {
            super.onResume();
            mSurfaceViewContainer.removeAllViews();
            mSurfaceView = new SurfaceView(mSurfaceViewContainer.getContext());
            mSurfaceViewContainer.addView(mSurfaceView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    
            SurfaceHolder previewHolder = mSurfaceView.getHolder();
            previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
            previewHolder.addCallback(mSurfaceHolderCallback);
        }
    

提交回复
热议问题