Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow setting the camera-facing attribute before starting the activity #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions demo/src/main/java/com/desmond/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.hardware.Camera;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
Expand All @@ -18,6 +19,7 @@
import android.widget.ImageView;

import com.desmond.squarecamera.CameraActivity;
import com.desmond.squarecamera.CameraFragment;
import com.desmond.squarecamera.ImageUtility;


Expand Down Expand Up @@ -89,6 +91,7 @@ private void requestForPermission(final String permission) {

private void launch() {
Intent startCustomCameraIntent = new Intent(this, CameraActivity.class);
startCustomCameraIntent.putExtra(CameraFragment.CAMERA_ID_KEY, Camera.CameraInfo.CAMERA_FACING_FRONT);
startActivityForResult(startCustomCameraIntent, REQUEST_CAMERA);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
// in the backstack will cause improper state restoration
// onCreate() -> onSavedInstanceState() instead of going through onCreateView()
if (savedInstanceState == null) {
mCameraID = getBackCameraID();
mCameraID = getActivity().getIntent().getIntExtra(CAMERA_ID_KEY, getBackCameraID());
mFlashMode = CameraSettingPreferences.getCameraFlashMode(getActivity());
mImageParameters = new ImageParameters();
} else {
Expand Down