不幸的是,android 6.01中的摄像头已停止错误

不幸的是,android 6.01中的摄像头已停止错误,android,android-intent,Android,Android Intent,Android 6.01给出了“不幸的是,相机停止了”如果在视频捕获时旋转手机,则会出现错误。这仅在Android 6.01更新中发生。所有其他Android Vision在捕获开始后会锁定摄像头。但如果旋转手机,则Android 6.01摄像头会旋转。默认摄像头中不会发生这种情况。仅当我们使用意图捕获视频时才会发生这种情况 活动\u视频\u应用程序\u main.xml <RelativeLayout xmlns:android="http://schemas.android.com/a

Android 6.01给出了“不幸的是,相机停止了”如果在视频捕获时旋转手机,则会出现错误。这仅在Android 6.01更新中发生。所有其他Android Vision在捕获开始后会锁定摄像头。但如果旋转手机,则Android 6.01摄像头会旋转。默认摄像头中不会发生这种情况。仅当我们使用意图捕获视频时才会发生这种情况

活动\u视频\u应用程序\u main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".VideoAppMainActivity">

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Record"
    android:id="@+id/recordButton"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Play"
    android:id="@+id/playButton"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:singleLine="true" />

<VideoView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/videoView"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_above="@+id/recordButton" />
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" tools:context=".VideoAppMainActivity">
    <item android:id="@+id/action_settings" android:title="@string/action_settings"
        android:orderInCategory="100" android:showAsAction="never" />
</menu>
菜单\u视频\u应用程序\u main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".VideoAppMainActivity">

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Record"
    android:id="@+id/recordButton"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Play"
    android:id="@+id/playButton"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:singleLine="true" />

<VideoView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/videoView"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_above="@+id/recordButton" />
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" tools:context=".VideoAppMainActivity">
    <item android:id="@+id/action_settings" android:title="@string/action_settings"
        android:orderInCategory="100" android:showAsAction="never" />
</menu>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="nigelhenshaw.com.videoapp" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".VideoAppMainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

strings.xml

<resources>
    <string name="app_name">VideoApp</string>

    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
</resources>

视频应用
你好,世界!
设置

从6.0棉花糖开始,您必须获得许可 android中有两种类型的权限 检查此链接

或者你可以试试这个代码

 private void requestPermission()
    {
        checkPermission();

        if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)){

            Toast.makeText(getApplicationContext(),"Storage permission allows us to send Image. Please allow in App Settings for Complete your order.",Toast.LENGTH_LONG).show();

        } else {

            ActivityCompat.requestPermissions(activity,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},PERMISSION_REQUEST_CODE);
        }
    }

    private boolean checkPermission(){
        int result = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
        if (result == PackageManager.PERMISSION_GRANTED){

            return true;

        } else {

            return false;

        }
    }
在单击时添加此项

// click of Button ImageCamera
case R.id.ImageCamera:
                if(!checkPermission())
                requestPermission();
                break;
还要将此添加到清单中

<!--external storage -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


尝试访问你的应用程序的权限可能是你没有权限访问它“Android 6.01提供”不幸的是,摄像头已停止“在视频捕获时旋转手机时出错”——除非你的应用程序名为“摄像头”,否则无论摄像头应用程序处理你的请求时,你都会看到一个错误。您对此无能为力。这不是权限问题。您可以添加崩溃日志吗?系统引发了什么异常?android 6.01中的每个android摄像头应用在捕获视频时都会发生这种情况。我想锁定摄像头旋转。android可以停止屏幕旋转,但我们不能停止摄像头旋转。这不是权限问题,这是在捕获时旋转时发生的。