onClick方法无法捕获未保存到图库的图像和文件

时间:2019-06-20 17:02:52

标签: java android android-camera

我正在尝试使用cameraKit库捕获图像,并使用onClick方法将其保存到我的画廊。 onClick方法不起作用,我不知道为什么,文件没有保存到图库或DCIM中。

我已为该应用添加了写入外部存储的权限,但这并没有改变。

import { Component, OnInit, Inject} from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA, MatTabChangeEvent } from '@angular/material';

  export class StockDetailComponent {
      public chart: ChartComponent;
      public ticker: string;
      public stockDetail: Stock;
      public intraDayChartAvailable: boolean;
      public dailyChartAvailable: boolean;
      public weeklyChartAvailable: boolean;
      public monthlyChartAvailable: boolean;
      constructor(
        private stockComponentSharedService: StockComponentSharedService,
        public dialogRef: MatDialogRef<StockDetailComponent>,
        @Inject(MAT_DIALOG_DATA) public data: any) {
          this.chart = new ChartComponent();
          this.ticker = data.ticker;
          this.stockDetail = data.stockDetail;
          this.intraDayChartAvailable = data.intraDayChartAvailable;
          this.dailyChartAvailable = data.dailyChartAvailable;
          this.weeklyChartAvailable = data.weeklyChartAvailable;
          this.monthlyChartAvailable = data.monthlyChartAvailable;
          this.intraDayChartAvailable ?      this.generateChart(this.stockComponentSharedService.getCachedStockData(this.ticker, 0),
          this.stockComponentSharedService.getCachedStockLabels(this.ticker, 0)) :
          this.generateChart(this.stockComponentSharedService.getCachedStockData(this.ticker, 1),
          this.stockComponentSharedService.getCachedStockLabels(this.ticker, 1));
       }

  public hideStockDetails(): void {
    this.chart.populateData([], []);
    this.stockComponentSharedService.clearTicker(this.ticker);
    this.dialogRef.close();
  }

1 个答案:

答案 0 :(得分:0)

是的,您已经在清单中添加了权限,但是如果您的设备是Android 6+,则应该检查运行时权限。在您的代码中,我找不到这部分。 Official Site of Android Developers说明了如何在运行时请求运行时权限。希望能帮助到你。

您应该询问使用相机以及保存照片的权限(读/写到外部存储器)