标签云

微信群

扫码加入我们

WeChat QR Code

Android 6.01 gives "Unfortunately,Camera has stopped" error if we rotate our phone while video capture.this is happen only in Android 6.01 update.all other Android visions lock camera after capturing start.But android 6.01 camera rotate if we rotate our phone.This is not happen in default camera.This is happen only if we use Intent to capture video.activity_video_app_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"><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Record"android:id="@+id/recordButton"android:layout_alignParentBottom="true"android:layout_alignParentStart="true" /><Buttonandroid: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" /><VideoViewandroid: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" />VideoAppMainActivityimport android.app.Activity;import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.provider.MediaStore;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.widget.Button;import android.widget.VideoView;public class VideoAppMainActivity extends Activity {private Button mRecordView, mPlayView;private VideoView mVideoView;private int ACTIVITY_START_CAMERA_APP = 0;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_video_app_main);mRecordView = (Button) findViewById(R.id.recordButton);mPlayView = (Button) findViewById(R.id.playButton);mVideoView = (VideoView) findViewById(R.id.videoView);mRecordView.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Intent callVideoAppIntent = new Intent();callVideoAppIntent.setAction(MediaStore.ACTION_VIDEO_CAPTURE);startActivityForResult(callVideoAppIntent, ACTIVITY_START_CAMERA_APP);}});mPlayView.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {mVideoView.start();}});}protected void onActivityResult(int requestCode, int resultCode, Intent data) {if(requestCode == ACTIVITY_START_CAMERA_APP && resultCode == RESULT_OK) {Uri videoUri = data.getData();mVideoView.setVideoURI(videoUri);}}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.menu_video_app_main, menu);return true;}@Overridepublic boolean onOptionsItemSelected(MenuItem item) {// Handle action bar item clicks here. The action bar will// automatically handle clicks on the Home/Up button, so long// as you specify a parent activity in AndroidManifest.xml.int id = item.getItemId();//noinspection SimplifiableIfStatementif (id == R.id.action_settings) {return true;}return super.onOptionsItemSelected(item);}}menu_video_app_main.xml<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" ><applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:theme="@style/AppTheme" ><activityandroid: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>


try to go to the permission of your appmight be u didn't have permission to access it

2019年04月19日54分45秒

"Android 6.01 gives "Unfortunately,Camera has stopped" error if we rotate our phone while video capture" -- unless your app is named "Camera", you are seeing a bug in whatever camera app is handing your request. There is little that you can do about this.

2019年04月20日54分45秒

This is not a permission issue

2019年04月20日54分45秒

Can you add crash log? What exception is thrown by system?

2019年04月19日54分45秒

this is happen in every android camera app in android 6.01 when capturing a video.i want to lock camera rotation.android can stop screen rotation but we can't stop camera rotation.

2019年04月20日54分45秒

This is not a permission issue this is happen when we rotate while capturing.

2019年04月20日54分45秒