क्या कैमरे का उपयोग टुकड़े में देखने के लिए संभव है, ताकि यह एक और ऐप नहीं खोल सके और मेरे से दूर जा सके? कैमरे के साथ SurfaceView
की तरह कुछ?खंड के अंदर खुला कैमरा
5
A
उत्तर
3
हाँ, यह है, इस पोस्ट की जाँच करें: https://www.airpair.com/android/android-camera-surface-view-fragment
मूल रूप से SurfaceView overwritting और कैमरा चित्र कॉलबैक को एकीकृत।
/* Surface on which the camera projects it's capture results.
*/
class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
SurfaceHolder mHolder;
Camera mCamera;
public CameraPreview(Context context, Camera camera) {
super(context);
mCamera = camera;
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
// deprecated setting, but required on Android versions prior to 3.0
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, now tell the camera where to draw the preview.
try {
mCamera.setPreviewDisplay(holder);
mCamera.startPreview();
} catch (IOException e) {
e.printStackTrace();
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
// empty. Take care of releasing the Camera preview in your activity.
}
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// If your preview can change or rotate, take care of those events here.
// Make sure to stop the preview before resizing or reformatting it.
if (mHolder.getSurface() == null){
// preview surface does not exist
return;
}
// stop preview before making changes
try {
mCamera.stopPreview();
} catch (Exception e){
// ignore: tried to stop a non-existent preview
}
// set preview size and make any resize, rotate or
// reformatting changes here
// start preview with new settings
try {
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
} catch (Exception e){
e.printStackTrace();
}
}
}
की तरह एक कैमरा चित्र कॉलबैक साथ
:
private Camera.PictureCallback mPicture = new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
File pictureFile = getOutputMediaFile();
if (pictureFile == null){
Toast.makeText(getActivity(), "Image retrieval failed.", Toast.LENGTH_SHORT)
.show();
return;
}
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
};
1
मूल निवासी कार्यान्वयन रास्ता बेहतर है।
एक्सएमएल
<com.google.android.cameraview.CameraView
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:keepScreenOn="true"
android:adjustViewBounds="true"
app:autoFocus="true"
app:aspectRatio="4:3"
app:facing="back"
app:flash="auto"/>
अंदर गतिविधि/टुकड़ा
प्रारंभ कैमरा
mCameraView.start();
रोक कैमरा
mCameraView.stop();
संबंधित मुद्दे
- 1. खंड पेज के अंदर ViewPager
- 2. 'कहां' खंड के अंदर 'अवरक्त-हैकेल-प्रकार'?
- 3. एसक्यूएल: IF क्लॉज के अंदर खंड
- 4. स्क्रॉल के अंदर Google मानचित्र खंड,
- 5. का उपयोग Spotify/कैमरा खुला साथ पृष्ठभूमि संगीत
- 6. मेरे ऐप नियंत्रक के अंदर कैमरा का उपयोग कैसे करें
- 7. एंड्रॉइड में खंड के अंदर व्यूपर को कैसे रखा जाए?
- 8. खंड
- 9. कैमरा फ्रेम कैमरा आईओएस
- 10. कैमरा
- 11. कैमरा
- 12. खुला एसएसएल
- 13. फ़ाइल खुला
- 14. एंड्रॉइड कैमरा 2 फ्रंट कैमरा
- 15. खंड
- 16. खंड
- 17. खंड
- 18. खंड
- 19. खंड
- 20. खंड
- 21. applescript के साथ खुला कार्यक्रमों
- 22. खंड
- 23. खंड
- 24. खंड
- 25. खंड
- 26. कैमरा के ऑटो-एक्सपोजर
- 27. उद्घाटन कैमरा प्रोग्राम के
- 28. गार्ड के बजाय एक सशर्त अभिव्यक्ति के अंदर कोड लपेटकर के खंड रेल
- 29. कैमरा खुला होने पर ग्रिड लाइनों को कैसे आकर्षित करें avcapturemanager
- 30. कैमरा 2 वीडियो रिकॉर्डिंग
इस भयानक है –