Camera2使用surface支持
surfaceview是运行在子线程,可以为相机提供不断的刷新 public class MainActivity extends AppCompatActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getSupportFragmentManager().beginTransaction().add(R.id.relative, new BlankFragment()).commit(); } } 主activity用于启动一个Fragment在fragment中启动相机 public class BlankFragment extends Fragment { public static final int REQUEST_CAMERA_CODE = 100; public static final String PACKAGE = "package:"; private static final SparseIntArray ORIENTATIONS = new SparseIntArray(); ///为了使照片竖直显示 static {