버튼을 누르면 MainActivity to CameraActivity에 카메라 미리보기 및 진행률 막대가 포함됩니다. 그러나 작업 스위치가 진행되기 바로 전에 진행 막대가 나타나기 때문에 MainActivity의 진행률 막대가 잠깐 보입니다. 무엇이 이것을 일으킬 수 있습니까? 감사합니다.Android - 다음 활동의보기가 너무 일찍 나타납니다.
다음은 관련 코드입니다.
MainActivity.java
public void openCamera(View view) {
if (getCameraInstance() == null) {
Toast.makeText(FeedActivity.this, "Camera is unavailable right now", Toast.LENGTH_LONG).show();
} else {
Intent i = new Intent(MainActivity.this, CameraActivity.class);
startActivity(i);
}
}
CameraActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera);
getSupportActionBar().hide();
progressBar = (ProgressBar) findViewById(R.id.progressBar);
animation = ObjectAnimator.ofInt(progressBar, "progress", 0, 100);
animation.setDuration(10000);
animation.setInterpolator(new LinearInterpolator());
// Create an instance of Camera
mCamera = getCameraInstance();
// Create our Preview view and set it as the content of our activity.
mPreview = new CameraPreview(this, mCamera, currentCameraId);
preview = (FrameLayout) findViewById(R.id.camera_preview);
preview.addView(mPreview);
}
/** A safe way to get an instance of the Camera object. */
public static Camera getCameraInstance(){
Camera c = null;
try {
c = Camera.open(); // attempt to get a Camera instance
}
catch (Exception e){
// Camera is not available (in use or does not exist)
}
return c; // returns null if camera is unavailable
}
감사합니다. 나는 당신이 비록 게시 한 링크를 사용하는 방법을 모르겠다. 그 것을 포함하는 새로운 수업을 만들고 대신 새로운 CameraPreview라고 부릅니까? 또한 중간 미리보기 (또는로드 미리보기)가 필요 없도록 카메라 로딩 속도를 최적화하기 위해 할 수있는 일이 있습니까? – Jill
콜백 사용 시도 mCamera.setOneShotPreviewCallback (previewCallback); previewCallback에서 progressbar 표시 –
@Jill 내 업데이트 된 답변 확인 –