- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
根据我的理解,onPause()
是在另一个 Activity 在它上面弹出时调用的。但在我的例子中,没有发生这样的事情,但是调用了 onPause()
并且 app 崩溃了
。想知道为什么会这样吗?
我把整个logcat贴在下面,你可以在里面搜索D/Camera2VideoFragment: onPause: In onPause
我还发布了我认为相关的功能代码块。
暂停
@Override
public void onPause() {
if(MyDebug.LOG)
Log.d(TAG, "onPause: In onPause");
closeCamera();
stopBackgroundThread();
super.onPause();
}
相机状态改变时的回调状态。
private CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() {
@Override
public void onOpened(@NonNull CameraDevice cameraDevice) {
if(MyDebug.LOG)
Log.d(TAG, "onOpened: This is called: " + System.currentTimeMillis());
mCameraDevice = cameraDevice;
//start the preview only if there's been no restart or the video is stopped.
if(NUM_OF_RESTARTS <= 0)
startPreview();
mCameraOpenCloseLock.release();
if (null != mTextureView) {
configureTransform(mTextureView.getWidth(), mTextureView.getHeight());
}
//Starts the video again when max file is reached.
if(MAX_FILE_REACHED)
startRecordingVideo();
}
@Override
public void onDisconnected(@NonNull CameraDevice cameraDevice) {
if(MyDebug.LOG)
Log.d(TAG, "onDisconnected: THIS IS CALLED: " + System.currentTimeMillis());
mCameraOpenCloseLock.release();
if(MyDebug.LOG)
Log.d(TAG, "onDisconnected: cameraDevice.close() is called here: " + System.currentTimeMillis());
cameraDevice.close();
mCameraDevice = null;
}
@Override
public void onError(@NonNull CameraDevice cameraDevice, int error) {
if(MyDebug.LOG)
Log.d(TAG, "onError: This is called with error: " + error+ " at: " + System.currentTimeMillis());
mCameraOpenCloseLock.release();
if(MyDebug.LOG)
Log.d(TAG, "onError: cameraDevice.close() is called here: " + System.currentTimeMillis());
cameraDevice.close();
mCameraDevice = null;
Activity activity = getActivity();
if (null != activity) {
activity.finish();
}
}
开始录像
private void startRecordingVideo() {
final Activity activity = getActivity();
if (null == activity) {
return;
}
if (null == mCameraDevice || !mTextureView.isAvailable() || null == mPreviewSize) {
if(MyDebug.LOG){
if(mCameraDevice == null)
Log.d(TAG, "startRecordingVideo: mCameraDevice is NULL: " + System.currentTimeMillis() + Thread.currentThread().toString());
if(!mTextureView.isAvailable())
Log.d(TAG, "startRecordingVideo: mTextureView is not available");
if(mPreviewSize == null)
Log.d(TAG, "startRecordingVideo: mPreviewSize is NULL");
}
return;
}
try {
closePreviewSession();
// Toast.makeText(activity," before setUpMediaRecorder " , Toast.LENGTH_LONG).show();
setUpMediaRecorder();
// Toast.makeText(activity," After setUpMediaRecorder " , Toast.LENGTH_LONG).show();
/**----------------------------------------------------------------------------------------*/
/**Setting up setOnInfoListener and setOnErrorListener to
* handle the video if it reaches max file size or if some error arises.
*/
mMediaRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() {
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
if(MyDebug.LOG)
Log.d(TAG, "MediaRecorder onInfo: " + what + " extra: " + extra);
final int final_what = what;
final int final_extra = extra;
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if(MyDebug.LOG)
Log.d(TAG, "run: calling onVideoInfo here: " + System.currentTimeMillis());
onVideoInfo(final_what, final_extra);
if(MyDebug.LOG)
Log.d(TAG, "run: returned here after onVideoInfo: " + System.currentTimeMillis());
}
});
}
});
mMediaRecorder.setOnErrorListener(new MediaRecorder.OnErrorListener() {
@Override
public void onError(MediaRecorder mr, int what, int extra) {
final int final_what = what;
final int final_extra = extra;
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
onVideoError(final_what, final_extra);
}
});
}
});
/**-----------------------------------------------------------------------------------------*/
SurfaceTexture texture = mTextureView.getSurfaceTexture();
assert texture != null;
// Toast.makeText(activity," setDefaultBufferSize " , Toast.LENGTH_LONG).show();
texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
mPreviewBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
List<Surface> surfaces = new ArrayList<>();
// Toast.makeText(activity," before Set up Surface " , Toast.LENGTH_LONG).show();
// Set up Surface for the camera preview
Surface previewSurface = new Surface(texture);
surfaces.add(previewSurface);
mPreviewBuilder.addTarget(previewSurface);
// Set up Surface for the MediaRecorder
Surface recorderSurface = mMediaRecorder.getSurface();
surfaces.add(recorderSurface);
mPreviewBuilder.addTarget(recorderSurface);
// Toast.makeText(activity," After mPreviewBuilder" , Toast.LENGTH_LONG).show();
// Start a capture session
// Once the session starts, we can update the UI and start recording
mCameraDevice.createCaptureSession(surfaces, new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
mPreviewSession = cameraCaptureSession;
// Toast.makeText(activity," before updatePreview" , Toast.LENGTH_LONG).show();
updatePreview();
// Toast.makeText(activity," After updatePreview" , Toast.LENGTH_LONG).show();
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
// UI
mButtonVideo.setText(R.string.stop);
mIsRecordingVideo = true;
// Start recording
if(mMediaRecorder == null) {
if(MyDebug.LOG)
Log.d(TAG, "onConfigured, run: mMediaRecorder is somehow null." );
}
mMediaRecorder.start();
}
});
}
@Override
public void onConfigureFailed(@NonNull CameraCaptureSession cameraCaptureSession) {
Activity activity = getActivity();
if (null != activity) {
Toast.makeText(activity, "Failed", Toast.LENGTH_SHORT).show();
}
}
}, mBackgroundHandler);
} catch (CameraAccessException | IOException e) {
e.printStackTrace();
}
}
LOGCAT
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Enabling debug mode 0
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2ebe9688 time:2777009
D/ROOT: Root access requested
D/Camera2VideoFragment: tryAcquire
I/CameraManagerGlobal: getCameraService: Reconnecting to camera service
E/Camera2VideoFragment: Couldn't find any suitable preview size
D/Camera2VideoFragment: openCamera: Intialising New MediaRecorder.
D/Camera2VideoFragment: openCamera: Manager.openCamera called here: 1532504895664
I/CameraManager: Using legacy camera HAL.
D/Camera2VideoFragment: onOpened: This is called: 1532504896165
I/CameraDeviceState: Legacy camera service transitioning to state CONFIGURING
I/RequestThread-0: Configure outputs: 1 surfaces configured.
D/Camera: app passed NULL surface
I/CameraDeviceState: Legacy camera service transitioning to state IDLE
I/RequestQueue: Repeating capture request set.
W/LegacyRequestMapper: convertRequestMetadata - control.awbRegions setting is not supported, ignoring value
W/LegacyRequestMapper: convertRequestToMetadata - Ignoring android.lens.focusDistance false, only 0.0f is supported
I/CameraDeviceState: Legacy camera service transitioning to state CAPTURING
E/BufferQueueProducer: [unnamed-8823-1] dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=6 undequeued=0)
E/BufferQueueProducer: [unnamed-8823-1] dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=5 undequeued=1)
D/Camera2VideoFragment: onClick: NUM_OF_RESTARTS click: 0
I/RequestQueue: Repeating capture request cancelled.
I/CameraDeviceState: Legacy camera service transitioning to state CONFIGURING
I/RequestThread-0: Configure outputs: 2 surfaces configured.
D/Camera: app passed NULL surface
I/CameraDeviceState: Legacy camera service transitioning to state IDLE
I/RequestQueue: Repeating capture request set.
W/LegacyRequestMapper: convertRequestMetadata - control.awbRegions setting is not supported, ignoring value
W/LegacyRequestMapper: convertRequestToMetadata - Ignoring android.lens.focusDistance false, only 0.0f is supported
V/RenderScript: 0xb7cfa0a0 Launching thread(s), CPUs 4
E/BufferQueueProducer: [unnamed-8823-2] dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=6 undequeued=0)
I/CameraDeviceState: Legacy camera service transitioning to state CAPTURING
E/BufferQueueProducer: [unnamed-8823-2] dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=5 undequeued=1)
D/Camera2VideoFragment: MediaRecorder onInfo: 801 extra: 0
D/Camera2VideoFragment: run: calling onVideoInfo here: 1532504954189
onVideoInfo: what: 801 extra: 0
onVideoInfo: Thread Name: main
onVideoInfo: MAX FILE SIZE APPROACHING
onVideoInfo: Calling stopRecordingVideo: 1532504954189
D/Camera2VideoFragment: restartRecordingVideo: Stoping Video From restart: 1532504954193
stopRecordingVideo: Stop Video Recording
stopRecordingVideo: About to call mMediaRecorder.stop()
W/Adreno-EGLSUB: <DequeueBuffer:736>: dequeue native buffer fail: No such device, buffer=0x0, handle=0x0
W/Adreno-EGL: <qeglDrvAPI_eglSwapBuffers:3709>: EGL_BAD_SURFACE
E/CameraDeviceGLThread-0: Received exception on GL render thread:
java.lang.IllegalStateException: swapBuffers: EGL error: 0x300d
at android.hardware.camera2.legacy.SurfaceTextureRenderer.checkEglError(SurfaceTextureRenderer.java:530)
at android.hardware.camera2.legacy.SurfaceTextureRenderer.swapBuffers(SurfaceTextureRenderer.java:523)
at android.hardware.camera2.legacy.SurfaceTextureRenderer.drawIntoSurfaces(SurfaceTextureRenderer.java:729)
at android.hardware.camera2.legacy.GLThreadManager$1.handleMessage(GLThreadManager.java:105)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
I/CameraDeviceState: Legacy camera service transitioning to state ERROR
D/Camera2VideoFragment: stopRecordingVideo: Done mMediaRecorder.stop()
stopRecordingVideo: Reset mMediaRecorder
stopRecordingVideo: Release mMediaRecorder
D/Camera2VideoFragment: stopRecordingVideo: Closing Camera: 1532504954421
closeCamera: mCameraDevice.close() called here.
E/RequestThread-0: Timed out while waiting for request to complete.
W/CaptureCollector: Preview buffers dropped for request: 1
E/CameraDeviceState: Cannot receive result while in state: 0
Cannot receive result while in state: 0
E/CameraDeviceState: Cannot receive result while in state: 0
W/MessageQueue: Handler (android.graphics.SurfaceTexture$1) {63c0706} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.graphics.SurfaceTexture$1) {63c0706} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:325)
at android.os.Handler.enqueueMessage(Handler.java:631)
at android.os.Handler.sendMessageAtTime(Handler.java:600)
at android.os.Handler.sendMessageDelayed(Handler.java:570)
at android.os.Handler.sendEmptyMessageDelayed(Handler.java:534)
at android.os.Handler.sendEmptyMessage(Handler.java:519)
at android.graphics.SurfaceTexture.postEventFromNative(SurfaceTexture.java:368)
E/BufferQueueProducer: [unnamed-8823-2] cancelBuffer: BufferQueue has been abandoned
E/BufferQueueProducer: [unnamed-8823-2] cancelBuffer: BufferQueue has been abandoned
E/BufferQueueProducer: [unnamed-8823-2] cancelBuffer: BufferQueue has been abandoned
E/BufferQueueProducer: [unnamed-8823-2] cancelBuffer: BufferQueue has been abandoned
E/BufferQueueProducer: [unnamed-8823-2] cancelBuffer: BufferQueue has been abandoned
D/Camera2VideoFragment: stopRecordingVideo: Opening Camera: 1532504958414
D/Camera2VideoFragment: tryAcquire
E/Camera2VideoFragment: Couldn't find any suitable preview size
D/Camera2VideoFragment: openCamera: Intialising New MediaRecorder.
openCamera: Manager.openCamera called here: 1532504958422
I/CameraManager: Using legacy camera HAL.
D/Camera2VideoFragment: onVideoInfo: came back here after restarting video recording: 1532504958920
run: returned here after onVideoInfo: 1532504958920
D/Camera2VideoFragment: onError: This is called with error: 1 at: 1532504958924
onError: cameraDevice.close() is called here: 1532504958924
D/Camera2VideoFragment: onClosed: Camera Closed: 1532504958954
D/Camera2VideoFragment: onOpened: This is called: 1532504958991
I/CameraDeviceState: Legacy camera service transitioning to state CONFIGURING
I/RequestThread-0: Configure outputs: 2 surfaces configured.
D/Camera: app passed NULL surface
I/CameraDeviceState: Legacy camera service transitioning to state IDLE
D/Camera2VideoFragment: onPause: In onPause
I/RequestQueue: Repeating capture request set.
W/LegacyRequestMapper: convertRequestMetadata - control.awbRegions setting is not supported, ignoring value
convertRequestToMetadata - Ignoring android.lens.focusDistance false, only 0.0f is supported
W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection
E/BufferQueueProducer: [unnamed-8823-3] dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=6 undequeued=0)
I/CameraDeviceState: Legacy camera service transitioning to state CAPTURING
E/BufferQueueProducer: [unnamed-8823-0] dequeueBuffer: BufferQueue has been abandoned
W/Adreno-EGLSUB: <DequeueBuffer:736>: dequeue native buffer fail: No such device, buffer=0x0, handle=0x0
W/Adreno-EGL: <qeglDrvAPI_eglSwapBuffers:3709>: EGL_BAD_SURFACE
E/CameraDeviceGLThread-0: Received exception on GL render thread:
java.lang.IllegalStateException: swapBuffers: EGL error: 0x300d
at android.hardware.camera2.legacy.SurfaceTextureRenderer.checkEglError(SurfaceTextureRenderer.java:530)
at android.hardware.camera2.legacy.SurfaceTextureRenderer.swapBuffers(SurfaceTextureRenderer.java:523)
at android.hardware.camera2.legacy.SurfaceTextureRenderer.drawIntoSurfaces(SurfaceTextureRenderer.java:729)
at android.hardware.camera2.legacy.GLThreadManager$1.handleMessage(GLThreadManager.java:105)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
I/CameraDeviceState: Legacy camera service transitioning to state ERROR
D/Camera2VideoFragment: onError: This is called with error: 1 at: 1532504959666
D/Camera2VideoFragment: onError: cameraDevice.close() is called here: 1532504959667
E/BufferQueueProducer: [unnamed-8823-3] dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=5 undequeued=1)
E/RequestThread-0: Timed out while waiting for request to complete.
W/CaptureCollector: Preview buffers dropped for request: 0
E/CameraDeviceState: Cannot receive result while in state: 0
Cannot receive result while in state: 0
E/CameraDeviceState: Cannot receive result while in state: 0
E/BufferQueueProducer: [unnamed-8823-3] queueBuffer: BufferQueue has been abandoned
E/BufferQueueProducer: [unnamed-8823-3] dequeueBuffer: BufferQueue has been abandoned
E/BufferQueueProducer: [unnamed-8823-3] cancelBuffer: BufferQueue has been abandoned
E/BufferQueueProducer: [unnamed-8823-3] cancelBuffer: BufferQueue has been abandoned
E/BufferQueueProducer: [unnamed-8823-3] cancelBuffer: BufferQueue has been abandoned
E/BufferQueueProducer: [unnamed-8823-3] cancelBuffer: BufferQueue has been abandoned
E/BufferQueueProducer: [unnamed-8823-3] cancelBuffer: BufferQueue has been abandoned
D/Camera2VideoFragment: onClosed: Camera Closed: 1532504963772
W/CameraCaptureSession: Session 1: The camera device was already closed:
java.lang.IllegalStateException: CameraDevice was already closed
at android.hardware.camera2.impl.CameraDeviceImpl.checkIfCameraClosedOrInError(CameraDeviceImpl.java:1482)
at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:677)
at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:328)
at android.hardware.camera2.impl.CameraCaptureSessionImpl.finalize(CameraCaptureSessionImpl.java:561)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:191)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:174)
at java.lang.Thread.run(Thread.java:818)
最佳答案
关于android - onPause() 被意外调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51513814/
我最近在/ drawable中添加了一些.gifs,以便可以将它们与按钮一起使用。这个工作正常(没有错误)。现在,当我重建/运行我的应用程序时,出现以下错误: Error: Gradle: Execu
Android 中有返回内部存储数据路径的方法吗? 我有 2 部 Android 智能手机(Samsung s2 和 s7 edge),我在其中安装了一个应用程序。我想使用位于这条路径中的 sqlit
这个问题在这里已经有了答案: What's the difference between "?android:" and "@android:" in an android layout xml f
我只想知道 android 开发手机、android 普通手机和 android root 手机之间的实际区别。 我们不能从实体店或除 android marketplace 以外的其他地方购买开发手
自Gradle更新以来,我正在努力使这个项目达到标准。这是一个团队项目,它使用的是android-apt插件。我已经进行了必要的语法更改(编译->实现和apt->注释处理器),但是编译器仍在告诉我存在
我是android和kotlin的新手,所以请原谅要解决的一个非常简单的问题! 我已经使用导航体系结构组件创建了一个基本应用程序,使用了底部的导航栏和三个导航选项。每个导航选项都指向一个专用片段,该片
我目前正在使用 Facebook official SDK for Android . 我现在正在使用高级示例应用程序,但我不知道如何让它获取应用程序墙/流/状态而不是登录的用户。 这可能吗?在那种情
我在下载文件时遇到问题, 我可以在模拟器中下载文件,但无法在手机上使用。我已经定义了上网和写入 SD 卡的权限。 我在服务器上有一个 doc 文件,如果用户单击下载。它下载文件。这在模拟器中工作正常但
这个问题在这里已经有了答案: What is the difference between gravity and layout_gravity in Android? (22 个答案) 关闭 9
任何人都可以告诉我什么是 android 缓存和应用程序缓存,因为当我们谈论缓存清理应用程序时,它的作用是,缓存清理概念是清理应用程序缓存还是像内存管理一样主存储、RAM、缓存是不同的并且据我所知,缓
假设应用程序 Foo 和 Eggs 在同一台 Android 设备上。任一应用程序都可以获取设备上所有应用程序的列表。一个应用程序是否有可能知道另一个应用程序是否已经运行以及运行了多长时间? 最佳答案
我有点困惑,我只看到了从 android 到 pc 或者从 android 到 pc 的例子。我需要制作一个从两部手机 (android) 连接的 android 应用程序进行视频聊天。我在想,我知道
用于使用 Android 以编程方式锁定屏幕。我从 Stackoverflow 之前关于此的问题中得到了一些好主意,并且我做得很好,但是当我运行该代码时,没有异常和错误。而且,屏幕没有锁定。请在这段代
文档说: android:layout_alignParentStart If true, makes the start edge of this view match the start edge
我不知道这两个属性和高度之间的区别。 以一个TextView为例,如果我将它的layout_width设置为wrap_content,并将它的width设置为50 dip,会发生什么情况? 最佳答案
这两个属性有什么关系?如果我有 android:noHistory="true",那么有 android:finishOnTaskLaunch="true" 有什么意义吗? 最佳答案 假设您的应用中有
我是新手,正在尝试理解以下 XML 代码: 查看 developer.android.com 上的文档,它说“starStyle”是 R.attr 中的常量, public static final
在下面的代码中,为什么当我设置时单选按钮的外观会发生变化 android:layout_width="fill_parent" 和 android:width="fill_parent" 我说的是
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
假设我有一个函数 fun myFunction(name:String, email:String){},当我调用这个函数时 myFunction('Ali', 'ali@test.com ') 如何
我是一名优秀的程序员,十分优秀!