CameraPreview在抖动中的怪异行为

时间:2019-09-29 15:41:21

标签: android flutter camera

我遵循了Flutter食谱中的使用相机拍照教程。我没有任何构建错误,应用程序中的所有程序都运行良好,但是导航到CameraHandler小部件时收到了此消息。它要求获得使用摄像头和录制音频的许可,但此后我看到的只是进度指示器。

E/libc    (32251): Access denied finding property 
"persist.vendor.camera.privapp.list"
W/gmess.pg_survey(32251): type=1400 audit(0.0:203606): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=18586 scontext=u:r:untrusted_app:s0:c13,c257,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
W/Binder:32251_3(32251): type=1400 audit(0.0:203607): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=18586 scontext=u:r:untrusted_app:s0:c13,c257,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
E/libc    (32251): Access denied finding property "vendor.camera.aux.packagelist"
E/libc    (32251): Access denied finding property "vendor.camera.aux.packagelist"
W/Binder:32251_3(32251): type=1400 audit(0.0:203608): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=18586 scontext=u:r:untrusted_app:s0:c13,c257,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0

这是我的CameraHandler小部件:

import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart' show join;
import 'package:path_provider/path_provider.dart';

class CameraHandler extends StatefulWidget {
  final CameraDescription camera;

  const CameraHandler({
    Key key,
    @required this.camera,
  }) : super(key: key);

  @override
  _CameraHandlerState createState() => _CameraHandlerState();
}

class _CameraHandlerState extends State<CameraHandler> {
  CameraController _controller;
  Future<void> _initControllerFuture;

  @override
  void initState() {
    super.initState();

    _controller = CameraController(widget.camera, ResolutionPreset.medium);
    _initControllerFuture = _controller.initialize();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Take pictures of PG')),
      body: FutureBuilder<void>(
        builder: (context, snapshot) {
          if (snapshot.connectionState == ConnectionState.done) {
            return CameraPreview(_controller);
          } else {
            return Center(
              child: CircularProgressIndicator(),
            );
          }
        },
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.camera_alt),
        onPressed: () async {
          try {
            await _initControllerFuture;

            final path = join(
              (await getTemporaryDirectory()).path,
              '${DateTime.now()}.png',
            );

            await _controller.takePicture(path);
            print('Took a picture from Camera!!');
          } catch (e) {
            print('Camera Error: ' + e);
          }
        },
      ),
    );
  }
}

这是我的AndroidManifest.xml,具有所有必需的权限:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"    />

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="pg_survey"
    android:icon="@mipmap/ic_launcher">
    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <!-- This keeps the window background of the activity showing
             until Flutter renders its first frame. It can be removed if
             there is no splash screen (such as the default splash screen
             defined in @style/LaunchTheme). -->
        <meta-data
            android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
            android:value="true" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

我要去哪里错了,请帮忙!

0 个答案:

没有答案