简体   繁体   English

nativescript angular2相机错误

[英]nativescript angular2 camera error

I'm trying to get the camera (hardware acces) to work in a nativescript angular2 app on Windows 10. 我正在尝试让相机(硬件配件)在Windows 10的nativescript angular2应用程序中工作。

But i'm keep getting errors after building in the command promp: - tns run android 但是在构建命令提示符后,我一直收到错误消息:-tns run android

this is my code: 这是我的代码:

app.component.ts app.component.ts

import { Component } from "@angular/core";
import cameraModule = require("camera");
import imageModule = require("ui/image"); 

@Component({
selector: "my-app",
templateUrl: "app.component.html" 
}) 

export class AppComponent {

public takePic() {
    cameraModule.takePicture().then(picture => {
        console.log("Result is an image source instance");
        var image = new imageModule.Image();
        image.imageSource = picture;
    });
}
}

app.component.html app.component.html

<StackLayout>
<Label text="Take a picture" class="title"></Label>

<Button text="take" (tap)="takePic()"></Button>
<Label [text]="take" class="message" textWrap="true"></Label>

and this is the error i'm getting: 这是我得到的错误:

EXCEPTION: Uncaught (in promise): Error: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/org.nativescript.camera/files/cameraPicture_1010201614233.jpg exposed beyond app through ClipData.Item.getUri()

I am just guessing here but most probably you are trying to take a picture in Android N (Android 7) and the thing is that targeting file:// URIs are not allowed anymore. 我只是在这里猜测,但很可能您是想在Android N(Android 7)中拍照,但事实是,不再允许目标file:// URI。 The new concept deals with files using content provider and that said NativeScript is implementing new optimized camera module which also handles the new files requirements for Android. 新概念使用内容提供程序处理文件,并且表示NativeScript正在实现新的优化相机模块,该模块还可以处理Android的新文件要求。 The new camera module is scheduled to be released with NativeScript 2.4.0 and can be found at this repository . 新的相机模块计划与NativeScript 2.4.0一起发布,可以在此存储库中找到。

At this thread , you can find a basic usage of the new camera plugin which also works with imageAssets (again if you want to test it now you will need tns-core-modules@next as this will be released in version 2.4.0) 此线程中 ,您可以找到新相机插件的基本用法,该插件也可以与imageAssets一起使用(再次,如果您现在要进行测试,则需要tns-core-modules @ next,因为它将在2.4.0版中发布)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM